Making static urls using mod rewrite | MyLiteratureTechLife.COM

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 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.

Related posts:

  1. Dynamic URLs and static URLs
  2. Five tips for search engine optimization while making a website
  3. Customize your default apache page in cpanel
SEO
 

If You Like This Post, Share it With Your Friends & Peers

Digg
stumbleupon
Delicious
facebook
twitter
reddit
rss feed bookmar
 

No Comment to “Making static urls using mod rewrite”

  1. No Comment yet. Be the first to comment...

Leave your comment here:

*

Alexa Rank