I just created a new subdomain for my blog so blog.example.com
- it used to be www.example.com/blog
so I am now trying to write 301 redirects from all my old /blog
posts to the new blog.example.com
URLs. I have placed the following code in my htaccess
:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^blog/(.*)$ http://blog.example.com/$1 [L,R=301]
However, do I put it after the # END Wordpress
in the htaccess
or am I missing something? Where in the htaccess
file do I put this code or is it even the correct code?
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
OR Do I need to write out
Redirect 301 /blog/example-post http://blog.example.com/example-post
Any help would be appreciated, thanks!
www
subdomain (and theblog
subdomain)? Does yourblog
subdomain point to the same document root as your main domain? Have you already changed the URL structure in WordPress itself? Have you actually tried this and what was the result?