user1778347
user1778347

Reputation: 13

Moving blog to subdomain

So I have tried to implement some solutions to my dilemma but they have all partially failed.

I have moved my blog from www.website.com/blog/ to blog.website.com

blog.website.com is in a directory outside of my root web directory

All urls are identical after the initial location: for example... old site www.website.com/blog/wp-admin = blog.website.com/wp-admin

This is a wordpress site if that helps or makes a difference.

This is what I have for now. Redirects main folder but not subfolders...

RewriteEngine on
RewriteBase / 

#if not already blog.website.com
RewriteCond %{HTTP_HOST} !^blog\.website\.com$ [NC] 
#if request is for blog/, go to blog.website.com
RewriteRule ^blog/$ http://blog.website.com/$1 [L,NC,R=301] 

Upvotes: 1

Views: 60

Answers (1)

Dan Barzilay
Dan Barzilay

Reputation: 4983

You need the (.*):

RewriteEngine on
RewriteBase / 

#if not already blog.website.com
RewriteCond %{HTTP_HOST} !^blog\.website\.com$ [NC] 
#if request is for blog/, go to blog.website.com
RewriteRule ^blog/(.*)$ http://blog.website.com/$1 [L,NC,R=301] 

Upvotes: 1

Related Questions