0
votes

Trying to set up a 301 redirect to forward all www traffic and subdomain traffic to domain.com

RewriteEngine On
RewriteRule ^/?wiki/(.*)$ /w/index.php?title=$1 [PT,L,QSA]
RewriteRule ^/?wiki/*$ /w/index.php [L,QSA]
RewriteRule ^/*$ /w/index.php [L,QSA]
RewriteRule ^(.*\.(css|js))$ min/index.php?f=$1&debug=0 [L,NC]

RewriteCond %{HTTP_HOST} !^domain\.com
RewriteRule (.*) http://domain.com/$1 [R=301,L]

Is from my htaccess file - can't for the life of me how to work out how to get the 301 to work properly.

At the moment www.domain.com/wiki/Main_Page redirects to domain.com/w/index.php/Main_Page

I'm sure it's something simple !

1

1 Answers

0
votes

At the moment www.domain.com/wiki/Main_Page redirects to domain.com/w/index.php/Main_Page

That is because your previous rules have already rewritten the request internally – and so (.*) matches not on the original request URI, but the current value.

Simply move your condition and rule for rewriting the domain up above all other rules.