Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
in Q2A Core by

Hi I would like to 301 redirect all non-www URLs in my music production Q&A section.  I noticed Google are indexing the non-www version which is not right.

This is the current question2answer htaccess:

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]
Any ideas how to revise the above htaccess so that it can redirect all non-www URLs to www for question2answer section only? Thanks.





1 Answer

0 votes


RewriteCond %{HTTP_HOST} ^(.*).your-domain.com [NC]
RewriteRule ^(.*)$ http://your-domain.com/$1 [L,R=301]
This does not work. Thanks anyway.