Apache’s mod_rewrite can be easily used via a file called “.htaccess” to turn dynamic urls into friendly urls.
Here is an example of how it’s done:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#Turn on the Rewrite Engine RewriteEngine on #Set the base path RewriteBase / #Check that the lookup isn’t an existing file RewriteCond %{REQUEST_FILENAME} !-f #Check that the lookup isn’t an existing directory RewriteCond %{REQUEST_FILENAME} !-d #Check that the file isn’t index.php (avoid looping) RewriteCond %{REQUEST_URI} !^index\.php$ #Force all .html lookups to the index file RewriteRule (.+)*\.html index.php?nav=$1 [QSA,L] #Note: QSA=query string append;L=Last, no more rules |
This will rewrite all paths ending in “.html” to your index file.
From there, it’s simply a case of tailoring the rewrite to your requirements.
Comment Policy:
Your words are your own, so be nice and helpful if you can. Please, only use your real name, not your business name or keywords. Using business name or keywords instead of your real name will lead to the comment being deleted. Anonymous commenting is not allowed either. Limit the amount of links submitted in your comment. We accept clean XHTML in comments, but don't overdo it please.