Sites

Wikipedia
SlashDot
Gentoo Linux
Loop-AES Encryption
Geoiptool

Thursday, July 2, 2009

How To Use Mod Rewrite to Clean Up URL's

If you have not enabled or setup Mod Rewrite Then Read This Guide Here.

Ok so lets compare these:

http://www.yoursite.com/index.php?p=contactus

With the power of the mod_rewrite apache module, we can make this URL much cleaner.

http://www.yoursite.com/contactus.html

so now that you get the idea, here is how the above can be accomplished:


RewriteRule ^([^/]+).html$ /index.php?p=$1 [QSA,L,NC]

Now If you wanted your URL to look like a directory, you would use this line instead of the previous line:

RewriteRule ^([^/]+)/?$ /index.php?p=$1 [QSA,L,NC]

This would return:

http://www.yoursite.com/contactus/


Bookmark and Share


No comments:

Post a Comment