Mobile app version of vmapp.org
Login or Join
Kevin317

: Redirecting from www.example.com/blog to blog.example.com I am about to switch my blog onto a subdomain blog.example.com so I can have two different WordPress themes installed. Currently, my blog

@Kevin317

Posted in: #301Redirect #Redirects #Subdomain #Wordpress

I am about to switch my blog onto a subdomain blog.example.com so I can have two different WordPress themes installed. Currently, my blog resides at example.com/blog and I was wondering if there were any special 301 redirects or issues that may arise? Would the below 301 redirect format work?

RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^blog/$ blog.example.com/? [L,R=301]


or should it be

Redirect 301 /blog blog.example.com/

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Kevin317

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ogunnowo487

Since you mention WordPress then only the first (mod_rewrite) solution will work reliably. WordPress uses mod_rewrite for internal routing, so you should also use mod_rewrite for external redirects. Redirect is a mod_alias directive and executes later in the request, so you could end up with a confusing redirect.

However, the redirect posted only redirects the home page of the blog. Presumably you also want to redirect all the internal pages as well? In which case you will need something like the following in .htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^blog/(.*)$ blog.example.com/ [L,R=301]


However, it might also depend on where the main domain and subdomain are pointing. Do they point to the same place on the file system? A subdirectory? Somewhere entirely different?

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme