Apache mod_rewrite - Pretty URLS - Database Sie

As a part of my new SEO Addiction, I am working on a database site in php. I do not want the pages to show up like http://www.somewebsite.org/index.php?parameter=7. I want them to show up like http://www.somewebsite.org/meaning_full_name.html. This makes them look static and is better for search engine ranking.

It took me forever to get this working and it is a relatively easy task. There are tons of tutorials on the web to figure out how to get the right regular expression going for your site design but there is one piece that was buried!

First, the normal part is that you have to have mod_rewrite enabled/installed and make sure it is not commented out in httpd.conf. Next you create a .htaccess file in the folder of the site you are working like:

*******************************************************************
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^books/([0-9]+)\.html$ index.php?parameter=$1
******************************************************************

The secret for me to get this to work was to also modify a line in httpd.conf and restart apache.  This line is:

AllowOverride All

I am the only one on this server so I put it under the <Directory></Directory> but it can be under virtual hosts as well.  Restart apache after this.  If you get stuck, this may be the trick you need!

Leave a Reply

You must be logged in to post a comment.