June 18, 2005

Redirect 301 in httpd.conf

There have been multiple forum discussions recently about the ability of Redirect 302's to "highjack" sites in Google due to Google's failure to fix this problem (Search Engine Watch) which Google has apparently known about for over a year (as well as Google's getting one of its own pages 302 highjacked recently).

On another server note, Threadwatch's Using Canonical Domains to Sabotage Competitors in Google discusses pointing links to either the www or non-www of domains for sites that do not redirect one to the other — thereby calling the attention of search engines to the one that is not being "used" (though it's hard to argue that one or the other is not being used if both are available). The point is that, while it's more user-friendly to allow sites to be reached by both versions of the domain (www.site.com and site.com), some search engines interpret these as different sites … thus, the same page being served via both www and non-www can be seen as duplicate pages, triggering a duplicate page penalty.

The problem is that many people don't know how to point both versions of the domain to the site — or, more correctly said, how to redirect one version to the other. For those who run their own servers, a better solution is to handle it in the server's httpd.conf file. Good data at HighRankings, especially Ron Carnell's explanation — brilliant as always.

[Added]: Since it looks like people may be searching for the actual code for redirects within the httpd.conf file, it's the same as the code to be used within an .htaccess file, with the addition of the virtualhost code:

<VirtualHost>
Redirect 301 / http://site.com/
</VirtualHost>

Of course, with the rest of the stuff you'd normally have in a virtualhost directive. Just add the code, upload the file, restart_apache … and test. Always test. <grin>

2 Comments to "Redirect 301 in httpd.conf"

  1. Harry Maugans says:

    However a lot of people are referencing this article to redirect their http://domain.com to http://www.domain.com.

    This code will accomplish that:


    ServerName domain.com
    Redirect 301 / http://www.domain.com/

    Simple. :)

  2. Diane Vigil says:

    True. I just like it the other way around — redirecting "www" to non-www.

    Specifying it in an .htaccess file in the root folder of the website is workable. Where one has access to the server configuration file (generally httpd.conf in Apache), I find that better, since the server gives that information when someone accesses the site — then it doesn't have to be looked up a second time (in the .htaccess).

    But both ways work. :)

Have your say ...

First-time comments will be held for moderation (but comments are appreciated). Otherwise, just be courteous. If your name is a bunch of keywords, your comment will be deleted. Don't post links unless highly pertinent. Posters must be 16 or older.

Manage your subscriptions

Archives
© 2004-2017 DianeV Web Design Studio. All Rights Reserved.
34 queries. 0.281 seconds.