mamesaye mamesaye - 24 days ago 6
Apache Configuration Question

htaccess 301 redirect subdomain to different domain

I want to redirect my subdomain to different subdomain on a different server.

blog.mydomainname.com -> mydomainname.otherdomain.com


I tried this on .htaccess unsuccessfully:

RewriteCond %{HTTP_HOST} ^blog.mydomainname.com$ [NC]
RewriteRule ^(.*)$ https://mydomainname.nationbuilder.com/$1 [R=301,L]


Where is the problem?

Answer Source

This should do the trick for you, just remove the '^'

  RewriteCond %{HTTP_HOST} ^blog.mydomainname.com$
  RewriteRule (.*)$ https://mydomainname.nationbuilder.com/$1 [R=301,L]