Skip to content


The Code For 1 Home Page Version – .htaccess Style

Several weeks ago I covered the concept that all home pages – and their respective URLs – are not created equal.

Then today I thought to myself, “hmmm, I wonder if I can find multiple home pages for the site we just launched on Monday?”  Yes, just launched a site and just remembered an invaluable aspect of deployment – have 1 version – just 1 version – for any page and every page.  That includes the home page too, quite obviously.

And what did I find?  You guessed it, more than 1 URL to find the same page/content for my HOME PAGE!!!  Development No-No, shame on me, tisk-tisk, what was I thinking?!?!?

www.site.com/ and www.site.com/index.php both resolved and displayed the same content.  With duplicate content of 1 page on a site not necessarily being a deathnail in terms of site performance in a search engine, but rather a developmental habit that helps send a message to search engines that “my site is legit, well-developed, and well thought out” – I’m glad I remembered – DUH!  (and that message is good to send to search engines at any time – FYI)

My uber-preference for all things Linux leads me down the path of Apache and the use of the oh-so-handy .htaccess file.  If you don’t know what any of that is, check the links at the end of this post.  But without further ado, here is the code that redirects the “index.php” or “index.html” page to the “.com/” that I desire:

RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteRule ^(([^/]+/)*)index\.php$ http://www.site.com/$1 [R=301,L]

All you need to do is update the bold sections so they reflect your need/site/coding preferences/tech specs and put that code in your .htaccess file, save, and you’re done.  For me, I had a page file “index.php” that I wanted to redirect/resolve to “www.site.com/” because that’s the way the site is branded, that’s the way the on-site links are set up to the home page, and that’s the way we’re getting inbound links.  We’re NOT getting inbound links to “www.site.com/index.php” and the specified domain for the site in Google WM Tools was “www.site.com/” – again, we wanted every instance of any traffic or link or search engine to find ONE path to the home page.

Hope this helps, Kyle

Linux    Apache Web Server    .htaccess

Posted in Work - SEO/SEM.

Tagged with , , , , , , .


0 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

You must be logged in to post a comment.