The blog section of a website moved from a subdomain to a directory of the main domain. I need to redirect all users visiting blog.site.com
to site.com/blog/
and the directory someone enters should be kept when forwarding, e.g. blog.site.com/post/welcome
should point to site.com/blog/post/welcome
I treid adding this to my .htaccess
file which I placed in the subdomain’s directory via FTP:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^blog.herderzeitung.de$ [OR]
RewriteCond %{HTTP_HOST} ^www.blog.herderzeitung.de$
RewriteRule (.*)$ https://herderzeitung.de/blog/$1 [R=301,L]
However, this doesn’t seem to be working. I was also wondering, what the most SEO friendly way is to achieve this (the site permanently moved to another domain).
Thanks in advance!
2
Answers
This seems to work:
Thank you everyone!
Try
I’ve escaped the dots, and anchored&normalized the pattern. Also switched it to temporary redirects (302); once you know it works, then change it to 301 again for SEO reasons.
And yes, as far as i know
301
s are the best method for retaining your search rankings and the like.