Quick trick for Pretty URLs
Most people utilize a CMS or Weblog software that automatically handles url rewrites, but what if you have a simple website that doesn't need quite the same treatment?
I came up with a quick down and dirty little trick to help overcome such an instance and I think you may find this useful.
Fire up your favorite text editor and open up create a .htaccess file (or modify the file that may be sitting in your root directory) and paste these lines in. Feel free to tweak them a bit to suit your needs, maybe you'll even find a better use for this method.
-
RewriteEngine On
-
RewriteBase /
-
RewriteRule ^admin/.*$ — [PT]
-
# Use the above line for a folder that you DON'T want to follow these rules
-
RewriteRule ^/?([a-zA-Z0-9-_/]+)/$ $1.php [L]
-
# Here's where the "magic" happens
-
# http://www.example.com/page.php — OLD
-
# http://www.example.com/page/ — NEW
And that's it! Pretty URL's on the easy.
Posted in Programming, SEO Be the first to comment! »

