resting
resting

Reputation: 17457

.htaccess from main to subdomain

I can't get the below redirection to work. It's redirecting properly when I enter mydomin.com in the address bar, but not when I enter www.mydomain.com

I want all access from www.mydomain.com and mydomain.com to go to sub1.mydomain.com.
Note that I have sub2, sub3, they have their own .htaccess files and these should not be affected.

redirectMatch 301 ^www\.mydoman\.com$ http://sub1.mydomain.com  
redirectMatch permanent ^www\.mydomain\.com$ http://sub1.mydomain.com

Upvotes: 0

Views: 42

Answers (1)

Shadow_boi
Shadow_boi

Reputation: 2198

try this:

#Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.mydomain.com$[OR]
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule ^(.*)$ http://sub1.mydomain.com/$1 [R=301,L]

Upvotes: 2

Related Questions