Making static urls using mod rewrite
December 20th, 2009
0 Comments
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:
#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 rulesThis 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.
Related posts:
- Dynamic URLs and static URLs
- Five tips for search engine optimization while making a website
- Customize your default apache page in cpanel
















No Comment to “Making static urls using mod rewrite”