Back to the main site

Nice URL feature

Noah's Classifieds supports using nice URLs. This means for example that the link of an ad details page can look like this:

  http://your.classifieds.site/item/10
  

instead of the conventional URL:

  http://your.classifieds.site/index.php?item/10
  

Besides that the former one is nicer, it is also said to be more search engine friendly.

Rewriting URLs in Apache is done through the mod_rewrite module of Apache 1 or Apache 2. If you click on the Check menu point as admin and the RewriteEngine is not yet enabled, the configuration script attempts to find out whether the rewrite module is available at all. In some cases, this can't be detected for sure (especially if Php is installed as a CGI binary).

The rewrite module is enabled in httpd.conf with the following line (make sure it is not commented out):

LoadModule rewrite_module modules/mod_rewrite.so

If the rewrite module is available, you should have a file under the classifieds installation directory called .htacces with the following content in it, in order to enable nice URLs:

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteRule .* - [env=REWRITE_ON:1]
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php?url=$1 [L]
</IfModule>

Note that Noah's Classifieds is actually installed with this default .htaccess, so in most of the cases, the nice URL feature must work “out of the box”! If after doing this, the nice url feature still doesn't work, or you experience unaccessible, forbidden, or in other ways destructed pages, you should also check the following:

<Directory /path/to/dokuwiki>
  AllowOverride All
</Directory>
Options +FollowSymlinks
RewriteEngine on
 
...etc.
RewriteEngine on
RewriteBase /noah
...
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /index.php?url=$1 [L]
...
...
RewriteCond %{REQUEST_FILENAME}       !-d
RewriteCond %{REQUEST_FILENAME}       !-f
RewriteCond %{REQUEST_URI} !^/stats/(.*)$
...