0

I want to redirect all www to non-www with a google friendly 301 in apache2.2

It works basically but when I enter www.test.net in the browser I get redirected to test.net// and I would prefer without the double slash.

This is in my VHOST:

RewriteCond %{HTTP_HOST} ^www.test.net [NC]
RewriteRule ^(.*)$ http://test.net/$1 [L,R=301]

EDIT: It is even worse:

www.test.net/home in the browser gets redirected to test.net//home

1 Answer 1

5
RewriteRule ^(.*)$ http://test.net$1 [L,R=301]

or,

RewriteRule ^/(.*)$ http://test.net/$1 [L,R=301]

The / is present in the string that's being matched, so you're adding the extra in your $1.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .