Tim Smith
Tim Smith

Reputation: 1

Subdomain 301 redirect (htaccess)

How could I redirect my subdomain to main domain name? For example, I would like to redirect media.www.example.com to www.example.com using htaccess 301 redirect.

Tried this, but it's not working:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^media.www.example.com$
RewriteRule ^(.*)$ http://www.example.com/ [R=301,L]

Upvotes: 0

Views: 2041

Answers (1)

Shuvo Shuvo
Shuvo Shuvo

Reputation: 329

Use this way

  RewriteEngine on
  RewriteCond %{HTTP_HOST} ^http://shop.example.com/test.htm[NC]
  RewriteRule ^(.*)$ http://www.example.com/test.htm[L,R=301,NC]

So your code will be like that....

RewriteEngine on
RewriteCond %{HTTP_HOST} ^http://www.media.example.com$
RewriteRule ^(.*)$ http://www.example.com/ [R=301,L]

Upvotes: 1

Related Questions