Creating friendly URLs with mod_rewrite

This programming tutorial will teach you how to build search engine friendly URLs in PHP, which contain keywords and use HTML extensions. We are going to use the htaccess file and mod_rewrite module running on an Apache server.
More PHP Resource

Creating search engine friendly URLs in PHP is easier than some may think. First you need to make sure your server can read .htaccess files, and that you have the mod_rewrite Apache module installed. The majority of webhosts have mod_rewrite active and are ready for rewriting URLs.

If you're running PHP on a Windows server (IIS), I'm afraid this method of rewriting URLs will not work for you.

Rewriting URLs with a query string


Most of the time you'll probably want to create URLs based on pages returned from a (MySQL) database. Say you have the following pages:

More resources for PHP-friendly URLs:


Other Options