Avoid duplicate content / Permanent Redirect 301

Alles, was den Apache betrifft, kann hier besprochen werden.

Avoid duplicate content / Permanent Redirect 301

Postby savant2k6 » 31. August 2009 10:15

Hello Friends,

i've got a question concerning the "duplicate content" problem with search engines (e. g. if you have both domains http://www.domain.com and domain.com active -> the search enginge detects the exact same content in both domains).

A lot of tutorials on the web tell me to use a .htaccess file to do a Permanent Redirect (301) from domain.com to http://www.domain.com - which makes sense.

My problem is, that i use a CMS on my Website, which comes with a pre-made .htaccess file, which i don't want to change.

Can't i tell the Apache2 Virtual Hosts configuration, that i have two hosts and redirect directly from the Virtual Hosts configuration. Like that:


Code for "main host" (http://www.domain.com)
Code: Select all
<VirtualHost *>
        ServerAdmin webmaster@domain.com
        ServerName www.domain.com
        DocumentRoot /var/www/domain/html/
        ErrorLog /var/log/apache2/domain/error.log
        LogLevel warn
        CustomLog /var/log/apache2/domain/access.log combined
        ServerSignature On
</VirtualHost>


Code for redirected host (domain.com)
Code: Select all
<VirtualHost *>
        ServerAdmin webmaster@domain.com
        ServerName domain.com
        redirect permanent / http://www.domain.com/
        ErrorLog /var/log/apache2/domain/error.log
        LogLevel warn
        CustomLog /var/log/apache2/domain/access.log combined
</VirtualHost>


Won't that work, so that google/yahoo etc. don't produce the "duplicate content" error?

Thanks for your help, friends!

Savant
savant2k6
 
Posts: 1
Joined: 31. August 2009 09:01

Return to Apache

Who is online

Users browsing this forum: No registered users and 24 guests