Resolve Canonical URL Looping in Apache
January 31, 2006
Interesting… I’ve come in contact with the canonical redirect issue before. Mostly it’s an issue of Apache 1.3 and redirecting the no-www version of a website to the www version (Apache 2.0, I’ve noticed, does a much better job of not getting caught in the loop), but redirecting index.php to root when Apache calls index.php is somewhat of a problem. Luckily, Oatmeal of SEOmoz has your solution:
- Copy index.php to another filename that is not set as a DirectoryIndex by apache, for this example we’ll be using sitehome.php
- Create an apache DirectoryIndex directive for your document root.
Set it to sitehome.php. Do not set the directive on a server-wide level
otherwise it may cause problems with other folders that still need to
use index.php as a directory index.
Put this in an .htaccess file in your document root:DirectoryIndex sitehome.phpOr if you aren’t using per-directory context files, put this in your httpd.conf<Directory /your/document/root/examplesite.com/>
DirectoryIndex sitehome.php
</Directory> - Clear out the contents of your original index.php file. Insert this line of code:
<? header("Location: http://www.example.com"); ?>
About
Welcome to the Topositionseo blog, your source for SEO news, information and interpretation. The Topositionseo blog is maintained by Dustin Frelich, Nobis Interactive's in-house search guru. His views and opinions do not necessarily reflect those of his employer.
Search
Subscribe
Archives
- Current
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006
- December 2005
- November 2005
- October 2005
- September 2005
- August 2005