user1449369
user1449369

Reputation: 67

How would I include www or non-www in a redirect?

RewriteCond %{HTTP_HOST} ^mysite\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.mysite\.com$
RewriteRule ^/?$ "http\:\/\/mysite\.com\/forum\/" [R=301,L]

This is causes a redirect WITHOUT the www whether the www. is used or not.

However, I want it to use the www if its used, or if its not used, dont include it (for cookie reasons)

IE

http://mysite --> http://mysite  
http://www.mysite  --> http://www.mysite 

Upvotes: 0

Views: 29

Answers (1)

poncha
poncha

Reputation: 7866

You can use the %{HTTP_HOST} variable in the redirect rule:

RewriteCond ^/?$ http://%{HTTP_HOST}/forum/ [R=301,L]

Upvotes: 1

Related Questions