URL Rewriting Clean Folders

Here are a couple lines I like to use on sites to force the www subdomain throughout the site and also keep folders clean – meaning no /folder/index.html or /folder/index.php, instead they automatically go to /folder/. These techniques involve a 301 redirect so all your link juice is easily transferred and you avoid any duplicate content penalties.

RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php|html|htm)\ HTTP
RewriteRule ^(.*)index\.(php|html|htm)$ /$1 [R=301,L]

  • Digg
  • TwitThis
  • del.icio.us
  • Netvouz
  • description
  • Reddit
  • Furl
  • NewsVine
  • Simpy
  • Slashdot
  • Spurl
  • StumbleUpon
  • YahooMyWeb
  • TailRank
  • Technorati
  • Facebook
  • Google
  • LinkedIn
  • Live
  • MySpace
  • Ping.fm
  • Yahoo! Buzz
  • E-mail this story to a friend!



Home | Apache | URL Rewriting Clean Folders