brpaz
brpaz

Reputation: 3658

apache mod-rewrite removing www from url

I want to remove www. from my site url. I have added this to .htaccess:

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

It works if I type www.domain.com/x but not if I type www.domain.com/x/y. The rewrite "eats" the x value.

Thanks for your help.

Upvotes: 0

Views: 535

Answers (1)

Kevin Sedgley
Kevin Sedgley

Reputation: 1069

Try using

 RewriteRule (.*) http://mydomain.com%{REQUEST_URI}

for your rewrite rule instead.

Upvotes: 1

Related Questions