2
votes

I am transferring my blog over from a subdomain to domain and was wondering how to write the very specific 301 redirects.

blog.domain.com/blog-post >> domain.com/blog-post

blog.domain.com/blog-post-2 >> domain.com/blog-post-2

We are leaving our current content service (Hubspot) which required the subdomain. I have about 20 URLs to redirect.

Thanks!

1
Did you try anything? - anubhava

1 Answers

0
votes

You can use this rewrite rule:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^blog.domain.com$
RewriteRule ^(.*)$ domain.com/$1 [R=301,L]

It will redirect requests for blog.domain.com/uri to domain.com/uri