Home > wordpress > move wordpress blog from root to subdirectory

move wordpress blog from root to subdirectory

am quite sure you will get a lot of tutorials for this topic

try this http://www.google.co.in/search?q=move+wordpress+blog+from+root+to+subdirectory

but that didn solve one particular problem,  redirecting the old url to new url.

earlier i had my blog in the root directory on my domain http://www.rajeshpg.com.i moved my blog to a subdirectory http://www.rajeshpg.com/blog.i reinstalled wordpress in the subdirectory,and import my earlier posts.

The problem is that the old url for a post (probably indexed by google) should be redirected to new url.

example:- http://www.rajeshpg.com/2007/01/javaxservletservletexception-path-loginlayout-does-not-start-with-a-character/ should be redirected to http://www.rajeshpg.com/blog/2007/01/javaxservletservletexception-path-loginlayout-does-not-start-with-a-character/

After googling for an hour i got the solution.

modify your .htaccess file(or create one) in the root directory with this code.

RewriteEngine On
RewriteBase /
RewriteRule ^(\d*)/(\d*)/(.*)$ http://yourdomainname.com/blog/$1/$2/$3 [L,R=301]

(\d*) represents a sequence of numbers.
(.*) represents sequence of characters.

note:- this solution works only for the urls of /year/month/title pattern of wordpress blog.

  • Share/Bookmark
Categories: wordpress
  1. June 10th, 2009 at 00:08 | #1

    Nice post, thanks.

  2. July 31st, 2009 at 00:56 | #2

    This was a handy article to be sure. Thanks for the .htaccess info.

  1. July 30th, 2009 at 21:03 | #1