Reputation: 59525
I am looking to move http://domain.com/blog
to http://blog.domain.com
.This also means that everything that trails /blog
for example /blog/post/1
will need to be routed to http://blog.domain.com/post/1
.
Upvotes: 1
Views: 1321
Reputation: 143946
Ensure that you've got content on blog.domain.com
. Specifically, if you go to http://blog.domain.com/post/1
you get served the correct content.
In the htaccess file in your domain.com
domain's document root, add (preferably above any rules you may already have there):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain.com$ [NC]
RewriteRule ^/?blog/(.*)$ http://blog.domain.com/$1 [L,R=301]
If you actually don't have any content at blog.domain.com
and it shares the same document root as domain.com
, then you'll need to add these additional rules:
RewriteCond %{HTTP_HOST} ^blog.domain.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}/blog%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}/blog%{REQUEST_URI} -d
RewriteRule ^ /blog%{REQUEST_URI} [L]
Upvotes: 3