Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
  • Register
Welcome to the Q&A for Question2Answer.

If you have questions about the platform, click here to ask and please use English.

If you just want to try Q2A, please use the demo, which also grants admin access.

Apr 29: Q2A 1.5.2

Google index with www and without

+2 votes
Hi,

is this a duplicate content problem? What I have to write in htaccess to prevent google from indexing http://domain.com and http://domain.com

I want only http://domain.com

At the moment, the htaccess looks as follows:

 

DirectoryIndex index.php
RewriteEngine On
#RewriteBase /your-sub-directory
RewriteCond %{REQUEST_URI} ^(.*)//(.*)$
RewriteRule . %1/%2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.*$ index.php?qa-rewrite=$0&%{QUERY_STRING} [L]
asked Nov 24, 2010 in Q2A Core by anonymous

1 Answer

+1 vote

 

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
answered Nov 25, 2010 by Frank Basti
thanks Frank. So this is to prevent google from indexing the www.domain.com? Doesnt clash with other rules? Cheers
It does a 301 redirect from the www version to non-www. It should be fine on its own and not conflict with other rules.