Moving a WordPress blog from a subdirectory to subdomain preserving permalinks

Many bloggers like to keep their blog in either subdirectory (ex: or subdomain (ex: Generally personal blogs are hosted under subdirectories and blog dedicated to services hosted under subdomains.

Anyway, if one want to move his wordpress blog from a subdirectory to a subdomain or vice-versa, it is possible to do so without loosing permalinks and traffic from search engines.

Listed below are steps with case of moving our orkutfeeds service blog from to You should change things accordingly as per your configuration.

[Note: Please configure subdomain first, it you are moving to a subdomain. Please create a subdirectory first if you are moving to a subdirectory.]

1. Configuring wordpress

Login to your wordpress dashboard and go to General settings tab. You will see WordPress address(URL) & Blog address(URL) settings. Change them to target URL.

In our case it was which I changed to

Change both URL settings carefully as one character mistake may result in disaster. Don’t worry nothing will be lost, only you will need to find a wordpress expert to fix it.

So after you are sure, press Save Changes button. You will see something like URL not found error but don’t get panic. It is expected as we haven’t moved/copied our blog files to subdomain yet. If your blog is high traffic blog then you may copy your blog files first as explained in next step.

2. Moving/Copying Blog Files

Moving files:

Now this step is trickiest one and your smartness will decide how long your blog will remain down.

If you have shell access to your webserver and its Linux/Unix based server then you can use mv command to move all blog files at once. It took less than 1 second in orkutfeeds case!

ex: $mv path_to_domain_dir/blog/* path_to_subdomain_dir/

Note that, here path_to_domain_dir and path_to_subdomain_dir should be replaced by actual paths as per your server configuration.

If your blog is high traffic blog, then you may open shell first and type such command in advance. Please DO NOT hit enter before performing step 1.

Also DO NOT attempt moving files using FTP clients.

Copying files:

This is for users who do not have shell access or have Windows server. This is good for high traffic site also.

Copy all files from one location to another location via FTP. Alternatively, you can use shell command to copy files if reason for this approach is high traffic to your site.

How you do this is your choice!

Once all your blog files are available at new location and you done with configuring wordpress as mentioned in step 1, you now either waiting on an error page, wordpress login page or settings page again.

Just refresh no matter what is next to your eyes. You should see now your wordpress blog at new location. If you don’t contact me ASAP, with as much details possible.

3. Creating/Updating .htaccess file to preserve permalinks

This part is essential to maintain permalinks and SEO juice. Again this is divided in two ways depending on your goal.

Moving from a subdirectory to a subdomain:

Under root directory of your site (this is different than root directory of your blog), create (or update if already exist) a .htaccess file. You need to add only 3 lines to it as shown in following example:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^blog/(.*)$1 [R=301,NC]

Please make 2 change to last line:

  • If your blogs’ subdirecotry have different name like wordpress, then replace first occurrence of blog with its name. (Ex: For wordpress, change ^blog/ to ^wordpress/)
  • Replace with your subdomain URL. DO NOT forget trailing slash (/).

Also delete or rename ‘blog’ subdirectory for .htaccess file to work.

Moving from a subdomain to a subdirectory:

Under subdomains root directory, create (or update if already exist) a .htaccess file. You need to add only 3 lines to it as shown in following example:

Options +FollowSymlinks
RewriteEngine on
RewriteRule (.*)$1 [R=301,NC]

Please make 1 change to last line:

  • Replace with your new blog URL. DO NOT forget trailing slash (/).

Thats All! Now all permalinks, including links indexed by Search Engines should work fine.

Ideally, if you can perform all above steps at the same time, the whole process will go unnoticed without any downtime.

If you have any questions/suggestions please feel free to use comment form below.

If you like this post, please check our ongoing series on best WordPress Plugins.


Bo Bjerregaard August 20, 2008


Great guide, it helped me out alot!

But I have a single issue 🙁

I am trying to move my blog from to and I copied the code into a fresh .htaccess file, and placed this in the root of my domain.

This causes all old links to cause this error:
“Redirect Loop

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.

The browser has stopped trying to retrieve the requested item. The site is redirecting the request in a way that will never complete.”

Do you have any idea why this is happening, and how might I correct the issue?

Rahul Bansal August 21, 2008

There may be some mistake in .htaccess file.
Can you just paste its content here?

Bo Bjerregaard August 22, 2008

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^blog/(.*) [R=301,NC]

The old directory was, as mentioned /blog.

Rahul Bansal August 22, 2008

There is one mistake on 3rd line.

Add $1 after
Correct it and it will work fine.

Bo Bjerregaard August 22, 2008

Thank you very much. It seems that I had not only screwed up during copy/paste, but had also copied the file into a wrong directory.

That’ll teach me to cd correctly 😛

Thanks for the correction, and for a good guide 😀

Rahul Bansal August 25, 2008

Glad to know it worked. 🙂

Dell October 21, 2008

I’ve tried the instructions above and got a redirect loop as well but my htaccess appers to have been correct and in the root directory.

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^wordpress/(.*)$1 [R=301,NC]

Rahul Bansal November 25, 2008

First sorry for late reply buddy as I was away on a long vacation… 🙁
Now just tell me if you named .htaccess file correctly. It contains dot(.) as part of it name.

If you are still facing some issue, please let us know.

Dell October 22, 2008

…the missing dollar sign above was sanitized by the blog

Dell November 26, 2008

Hey Rahul,

Thanks for the reply. I’ve since solved the problem which I’ve documented as my first blog post: WordPress & GoDaddy. Thanks again.

Rahul Bansal November 26, 2008

Glad to know that.
And nice post too.
Happy blogging… 🙂

Saif December 3, 2008

Hi Rahul

can you let me know what I Would change in the .htaccess file if I was moving my blog from my main site to a subdomain. So from to


Rahul Bansal December 6, 2008

Your problem is more complicated buddy.

You need third line to be like…

Options +FollowSymlinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*)$1 [R=301,NC]

But this will conflict with ur top-domain if you host another wordpress or similar site there.
Try this and send me details if you stuck.

As I said, your case is different, I need more details to see what can be done.

Cooltallaware December 20, 2008

Excellent article… Successes and prosperity to you!

Rahul Bansal December 20, 2008

Thanks buddy… 🙂

Kris Tuttle March 25, 2009

I’m doing this and have a question. My host allows me to create the domain and point it to /blog which is where my blog is already. If I just do that and update my feedburner won’t it do the trick? In that case I wouldn’t have to move any files or anything.

But that seems too easy.

Kris Tuttle March 25, 2009

I want to amend my comment with the understanding that I need to then update the htaccess to make sure that old links directly to are pointed to

Kris Tuttle March 27, 2009

Okay I need some help. Things seemed to work BUT I didn’t change the wordpress and blog URL and now I cannot access my wp-admin and so forth. Is there a file on WP that I can modify that will set it right?

Or do I have to reverse the process or reinstall WP (I have a backup of everything of course.)

Rahul Bansal April 21, 2009

Your wordpress login URL is at
You can place a .htaccess file in
Refer above post for .htaccess content.

Great if all is working without any problem! 🙂
Moving and copying both results in same end result.
Copying is too play safe. So that if something goes wrong your blog doesn’t break

M April 9, 2009

AWESOME post Rahul. I was so scared of doing this (I usually wreck things, even though I’m a developer), but I was surprised that it only took me about 3 minutes to fully move it as you’ve described.

I just wanted to say that I’ve actually moved (not copied) the files via FTP, and I didn’t have any problems.

Frederick Guardian April 30, 2009

I’m trying to do something similar but I’m not having any luck. I have my website on a subdomainm Now it’s not a wordpress installation but this is the best thread I’ve found in the last few days.

My entire installation is also accessible through

What I’m trying to do is come up with a rewrite rule to redirect all the existing links from to, but the best results I’ve had so far is that when and, all point to just but what I really want to happen is goes to

When I thought I had the code in place that would work i just get an Internal Error. I’ve been editing the htaccess file in the subdomain folder, which is where the installation is for which is the exact same installation location as

Do I need to modify htaccess on the root as well and how can I do what I’m trying to do without writing in each individual rewrite rule for every single page on my website, that would take way too long. It seems it would have to be very easy to just swap with for every single page when someone tries to access it through the subdomain instead of the folder.

Rahul Bansal May 1, 2009

I am really sure that there must be an error in .htaccess file.
If .htaccess has correct code, you would have redirected to right link.

Please paste your .htaccess content here.

Frederick Guardian May 1, 2009

This is the base file that my CMS Installation put in the folder (drupal) I had to remove the lines I added because, like i said, the site is high trafficed and I can only take it down for seconds if it’s not functioning right I rewrite with a fucntioning file.

I’m not sure if I have the code I was putting in to recreate the Internal Errors but I’ll try to recreate it.

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteRule (.*)\.xml(.*) $1.php$2 [nocase]
DirectoryIndex index.php
ErrorDocument 404 /processor.php

Here is what I was modifying too in a ton of variations

RewriteEngine on
RewriteBase /
RewriteCond %(HTTP_HOST) ^$
RewriteRule (.*)$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
RewriteRule (.*)\.xml(.*) $1.php$2 [nocase]
DirectoryIndex index.php
ErrorDocument 404 /processor.php

I wish I had the exact code, but I added two lines, I think the code I have in now was redirecting to but not to the specific page it was for so all my pages were just going to the which I can’t have happen, I need all the links to be seemlessly migrated to the new URL.

You probably already know what it should say though or what the correct code is without me figuring out what I had in there that I thought should solve the problem but instead was recreating internal errors.

Rahul Bansal May 1, 2009

Do not modify any file created by Drupal including .htaccess
Move (better copy) them (every file, folder, images, .htaccess, etc) as it is to directory.

Then make sure if Drupal is working fine at new address i.e.
You may need to edit database or some file which tells drupal site url. You can search for value and replace it with
You may need to use PhpMyAdmin if Drupal stores site url information in database (most CMS stores such info in database only).
If it is storing in file you need to do search and replace in that file.
Check Drupal docs for help at this point.

Now as a test make sure correct page is served at new location.
As an example, content at “” and “” should be same.

Once above test works correctly, then only do following change.

In root folder for there must be a .htaccess file (from which you have copied above code).
Rename it to .htaccess.bak
This will create backup of .htaccess file.

Then create a new .htaccess file with code of format…
Options +FollowSymlinks
RewriteEngine on
RewriteRule (.*)$1 [R=301,NC]

Frederick Guardian May 1, 2009

Thanks for the advice above, the htaccess file I copied from and pasted in here is in the root directory of the subdomain folder which is just one layer down from the root.

But you can also access the drupal installation by going to root/folder so if I go to URL I can access the drupal installation, but only the main page, none of the the links work via the folder.

So as far as moving it, I wouldn’t know how to do it, the drupal installation is in the location I need it to be already which is the exact same location as

I’m not sure if I’m explaining it correctly but the directory the subdomain points to is the exact same folder I want it to redirect to and it’s already accessible there because it’s the same location, ie, I have a folder called subdomain one level down from root which is accessible from and Maybe this is why I’m having problems with the rewrite? It’s the same htaccess file for both locations.

So if I were to change the htaccess file for drupal that is in the root directory that the subdomain is using, it wouldn’t be good because it’s the same file.

What I’m trying to accomplish is to just have my site be accessible through the subdomain folder off the root instead of the subdomain.

So I think I’m starting to understand where the problem is. Should I make a new folder under the root, copy drupal installation to it, update the SQL Database URL references, change base url in the settings.php for the drupal install, and then once that is working I would modify the htaccess file in the old folder to rewrite to the new location?

Or is there a way to specify in the htaccess file or somewhere else that when the website is accessed from google or other links via that it just reroutes it to so that it doesn’t try to do anything funky when people do actually get to Like if I could just use a specific hard coded URL that i want it to redirect that wouldn’t affect anything else, since it’s the same htaccess file in both locations already.

Thanks a lot you’re helping me understand the dilemma a little better.

Or am I way off on this one.

Rahul Bansal May 8, 2009

Sorry for delayed response buddy.

There is a complex solution available for your problem. Also it depends on your hosting company.

Basically you can modify where your subdomain will point. So by changing directory name which is getting mapped to subdomain you will free up your URL

Do one thing, if you are still having problem with this contact me via email at [email protected]

There is no generic How-To solution for your problem. We need to first check which webhost you are using, which cpanel they are providing, also if you are allowed to access your server and mainly if you are permitted to manage apache’s vhost configuration.
This may sound too much work, and it is too much work for real. But things can be made to work for sure. 😉

Pavan Kumar May 1, 2009

Hi Rahul,

Here I need one help related with this.

Recently I removed global translator plugin (mostly it is temporary). As you might know, GT creates translated pages based on folders like italian version of my site would be accessed at The problem now is I have removed my translated pages and they all are resulting in 404s, but I would like to redirect all them to related page on my English main website.

If someone is driven to I want him to be redirected to and I want that to be a 302 redirect as I may make use of the plugin again.

I tried to make use of the method you said above, but somehow failed to succeed, and in my case all should be written in the same htaccess file. Could you please help me with codes.


Rahul Bansal May 8, 2009

I guess your issue has been fixed as we talked in scrap!
Let me know if you want .htaccess for your problem. 😉

Pavan Kumar May 8, 2009


The problem was solved automatically by the Platinum SEO plugin, but sharing the solution here would help someone who fit into my shoes.

And what I needed was a 302 redirect, but this plugin gave 301s 🙁

Rahul Bansal May 12, 2009

You may create something like below in your .htaccess.
Following is for language ‘it’ i.e. italian.
Add codes for other languages on similar lines.

RewriteRule ^(it/)(.*)$2 [L]

Also above are 302 redirects! So you consider using them instead Platinum SEO plugin.

Pavan Kumar May 12, 2009

Thanks dude… that’s of help 🙂

Rahul June 17, 2009


I tried that and just at the first step I got the error message as you told. I had not read “don’t worry” part and sureshot got panic and went and changed what to what I originally had ( now I am not getting anywhere. I know the installation is there but not getting it back properly.

Please help.

Rahul Bansal June 26, 2009

Just checked your blog.
Everything is seem to be working fine.
Did I miss something?

Rahul Bansal July 31, 2009

Sorry for late reply.
Can you provide more details?
I see as working fine

Techie Zone June 25, 2009

I am trying to move from structure to

But I am not sure if the page rank of will be transferred to

And could you also list the pros and cons of both?

Rahul Bansal June 26, 2009

Page rank will move if you keep htaccess at as mentioned in the post.
If you put something else at, then page rank may break!

Techie Zone June 29, 2009


I am trying to move from to Using the following in htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^$
RewriteRule ^/?(.*)$ “http\:\/\/domain\.com\/$1” [R=301,L]

with this whenever I try to click on a permalink from That is from google search it is going to and not to the exact location of the post.

Will be glad if you through some lght..

Rahul Bansal July 9, 2009

I guess following code should work well enough for you.
Put them in .htaccess file at I am assuming that you already moved all content and followed other steps in above post.
Options +FollowSymlinks
RewriteEngine on
RewriteRule (.*)$1 [R=301,NC]

prazetyo July 14, 2009

I have wordpress installation at All posting and comment running well at this URL. When I want to change this subdirectory to sub domain, why all my permalink get error? few of my image also missing.

I already change the WordPress Address and Blog Address at Setting > General. Is there any problem with my htaccess ?
# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

James Laws July 28, 2009

I am guessing my issue is similar but nothing seems to be working.

I installed WordPress at and everything worked fine with “pretty permalinks”. I then decided to have the blog at so I created the subdomain and pointed it to the directory. I updated the paths in the general settings and the blog loads fine but the permalinks no longer work. It only works if I use the wordpress default permalink settings.

Any idea how I would fix this?

Rahul Bansal July 31, 2009

Try this:

First, whatever steps you performed earlier were right. So if you have rolled back them, do it agian.
Now login to Dashboard. Go to “Settings” menu.
You will see “WordPress address (URL)” and “Blog address (URL)”. They will have value like “”. Change it to “”
Save Changes. You may get “error” message when you will save changes. Don’t worry. Just go to “” and check if everything is working fine.

You may need to update .htaccess file in root directory of “” to redirect traffic coming to your blogs from old permalinks.
Use above .htaccess codes for guidance.

Seth September 14, 2009

Can I use this .htaccess method if I want to move my blog from the /blog folder to the root directory? Or would the .htaccess rules be slightly different? Basically I want to move wordpress to the root directory of the site without breaking any permalinks.
Thanks for any help!

Rahul Bansal September 14, 2009

Following code should work for you…

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^blog/(.*)$1 [R=301,NC]

Replace with your sites root URL. Be careful with slashes (/).

Seth September 14, 2009

Thanks, Rahul! I’ll give it a try.

Seth September 15, 2009

I just want to confirm something before I try your suggestion, to make sure I understand the process. Once I set up the .htaccess in the root directory as you indicated, and have moved all the wordpress files in /blog to just / and updated the wordpress address and blog address from within wordpress (BEFORE moving files, I know), any links that refer to /blog are automatically redirected to just / before the page even loads in the browser, right? So it doesn’t matter that the /blog directory is deleted, ya? Thanks!

Seth September 19, 2009

…okay this is the code I’m using in the .htaccess file to redirect things from /blog to /:

Options +FollowSymLinks
RewriteEngine on
RewriteRule ^blog/(.*)$$1 [R=301,L]

I don’t know what the difference between “NC” and “L” is, but all the examples I could find elsewhere seemed to use the latter.

Also it seems the $ after ^blog/(.*) is important, signaling the end of the string… was that just accidentally left out of the above example?

In any case, it didn’t work at first and I don’t know why. I called my server (1and1) and was on with them for over an hour… they couldn’t figure it out either. But then after a few hours I came back and it seemed to be working fine, so I don’t know if they did something on their end or what. I don’t care as long as it keeps working!

Photographer London October 9, 2009

Just wanted to say thank you very much for this post. Had been trying to move my blog from a subdomain back to the main domain and this explained pretty much everything. As I’m using permalinks, the only additional step I had to take was to update the .htaccess file as per point 10 here:
Thanks again.

Jason October 28, 2009

Thanks for this great post and all your responses in the comments. Unfortunately, nothing seems to work for me. The story is this: I had two blogs on blogger, each of which used a subdomain structure with my custom domain name, and

I can get each of the subdomains to redirect to my new wordpress blog, but I cannot get the individual posts to redirect. For example, will not redirect to the answerable wordpress post. I have used the following code in the .htaccess file in my subdomain on the new DNS location:

Options +FollowSymlinks
RewriteEngine on
RewriteRule (.*)$1 [R=301,NC]
RewriteRule$$1 [R=301,NC]

No matter what I try (with or without the $, etc.), it doesn’t work. The only thing I can get to redirect is the domain itself, but none of the posts. What am I doing wrong?

Kimberley November 9, 2009

I’ve wanted to move wordpress from the subdirectory to a subdomain –

I created subdomain – which points at first.

Then changed my wordpress and blog address URLS to

I moved all my wordpress files over to

Then added the .htaccess file to my root –

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^blog/(.*)$1 [R=301,NC]

At this point, when I go on it forwards me to however if I delete the /blog subdirectory like told to in your instructions, when I type in it comes up with a 404 error page.

What shall I do? Leave the blog subdirectory there? I’m sorry if this seems pointless as it does work in a way, I’m just worried as it wasn’t exactly to what you said.

liza February 11, 2010


For SEO reasons, I’ve decided to move my 3 year subdomain blog ( to subdirectory ( The subdomain blog is now PR5 and receives good traffic. we have an big list of URLs in the index of major search engines. My question is, would it be good decision? Can you tell how big the impact would be with regards to our previous SEO efforts? Thanks!

Rudy July 9, 2010

I have a question that parallels Liza’s. In that I want to move my existing blog at to either or Whichever will provide the best SEO going forward and not lose any existing SEO generated.

In addition, I will be replacing the main domain with an e commerce site. What is the best way to achieve this with the best solution for SEO?

Thanks in advance!

Benji September 22, 2010

I tried moving my wordpress to a subdomain, I changed the URLs and moved the files like explained adove. The page works at the new location, except I can’t log in through the wordpress admin screen, when i try to and hit enter, it directs me to a page not found screen. Any ideas what I may have done wrong? Thanks so much!

VivBounty October 7, 2010

Hi Rahul,
Great Tutorial. I have moved my blog to a subdomain. I changed URLS and files as you instructed. The blog works fine. See my Website address above, but on my main domain now my error 404 document does not come up. I am getting Error 500 like this:

~~Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.~~

I think this is my .htaccess file. Here is what it looks like:

ErrorDocument 404 /vb_404.html
Options +FollowSymlinks
RewriteEngine On
RewriteBase /petblog/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /petblog/index.php [L]
RewriteRule ^petblog/(.*)$1 [R=301,NC]

My blog used to be at

I would appreciate any corrections to my .htaccess you might be able to provide to make my error404 doc work on my main domain.

Thanks in advance,

nikitha December 9, 2010

how to transfer from a sub domain to a sub domain dude ???? please help me …

thank you ..

Scyfox February 14, 2011

Hi there.

Thanks a lot for your tutorial. But i’d like to add a couple of things, because i had some issues moving from /blog to

First of, as soon as you can log in to the admin panel, make sure to go to the Plugins Tab and disable them all. This because a lot of the config files keep records on plain text in the options table of the plugins, pointing to the old address.

Then you can go and set them up one by one to confirm they have the new url correctly saved and without issues on your blog.

The other thing that is important is to enter the “Permalink” tab. Even though it might have written the correct URL for the links, press the SAVE button to “refresh” the database.

This would avoid the “404 not Found” post/article/page issue.

Also if you are getting “500 Internal Server Error”, you might have to edit the WordPress .htaccess file and comment the info using # at the beginning of the file because it makes a horrific loop inside the server.

I hope this answers everybody’s problems as I had to figure them out.

Thanks a lot again!!

Greets From Chile!

Dustin Macheske March 3, 2011

Thanks for the post on how to move my blog from root to a sub domain, you saved my life. My blog was getting hard to manage within wordpress when I wanted to add links, and I was tired of trying to add these links within the themes. Thanks again.

mrugesh shah March 15, 2011


I had installed wordpress on root. say for example :

I was posting there since last 2 years.

Now I have shifted that blog to :

and then installed a fresh wordpress on root at :

So my old article links is broken.

Can you please guide me, how I can reduce effect of SEO. Where I should put .htaccess file and what I should write in that ?

please help.

Carrie April 3, 2011

I moved my site from a subdomain to the root and it all works fine except the Home page won’t show up! It goes to my Coming Soon page rather than the actual content that should be there. What could be the problem?!
The site is here.


Rahul July 10, 2011

If you want to change the all URL from you database so may be this helpful to you.

UPDATE wp_options SET option_value = replace(option_value, ‘’, ‘’) WHERE option_name = ‘home’ OR option_name = ‘siteurl’;
UPDATE wp_posts SET guid = replace(guid, ‘’,’’);
UPDATE wp_posts SET post_content = replace(post_content, ‘’, ‘’);

Amandeep Singh August 2, 2011

Hi Rahul,

I am migrating my brother’s current blog from to

As the subdirectory name is blog and the subdomain is mag, does this process still hold good? I have done all the processes listed above and in .htaccess I am using:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^blog/(.*)$1 [R=301,NC]

Is this fine? I am unable to see any of the 2 – neither /blog or

Can you please help? My bro’s blog is down and I am going to get killed 🙂


Amandeep Singh August 2, 2011

Any updates on this brother?

Thomas Leichardt March 19, 2012


FYI I also had to add this line to the .htaccess file:
redirect /olddirectory
because would not redirect with your .htaccess mod and all other links redirected but not (w/o trailing slash)
All the other permalinks redirected like a charm, and with the extra line (w/o trailing slash) also redirected.

Another thing, at first I couldn’t get it to work because I was not moving files from olddirectory. I didn’t have the need to put them in a new directory, however, the .htaccess file would not start redirecting until I did move the olddirectory to a new one. That is, at first I just pointed the subdomain to my old directory, trying to save a step, but then I changed old directory name to a new name, and repointed my subdomain. Now it works perfect!

Thanks again for the great and simple instructions!


SmokeJohn August 24, 2012

Hi Rahul,
its been 4 years you are responding to your initial post: thanks again ! i have a question related to this 😉
my WP site is the WP files are located under a subdirectory /prod/web
i want to setup another WP site with a subdomain for test purpose under a subdir /test/web

So its about 2 WP (no multisite at all) with their own database. One under the root domain and under a subdirectory and the second under a subdomain and a subdirectory
What .htaccess should i create under my root directory and under my /prod/web directory and under my /test/web directory ?


Rahul Bansal August 24, 2012

Your case is totally different than article posted above.

You need to change paths in Apache virtual host config files.

Sample config will look like below:

<VirtualHost *:80>
DocumentRoot /prod/web
#other directives

and for

<VirtualHost *:80>
DocumentRoot /test/web
#other directives

Depending on your setup, you may find above files in /etc/apache2 dir.

If you do not have shell access to your server, and manage things via cPanel only, its better to contact cPanel forum. I not sure if they allow manual edits to Apache config.

SmokeJohn August 25, 2012

Thanks for this answer.
My problem is that i do not have access to Apache config. So im afraid i have to make some tricks with the root .htaccess…
but i run into many problems because of my lack of mastering this file 😉

Rahul Bansal August 25, 2012

I guess you wont be able to achieve this using .htaccess changes.
May be cPanel has an option to select folder location when creating site. Check with it.

SmokeJohn August 25, 2012

Eventually i succeed: i don’t need any trick with my hosting:
* the subdomain is pointing “natively” on my /www/test/web dir, so no need to set anything on the .htaccee root directory in /www
* the main domain is pointing “natively” on my /www/ root directory. So, im in the case described in the wordpress codex

thanks for your response !

sulabh August 30, 2012

i want to update wordpress site as “”
which is currently “”
the “blogname” will change for each blog, it will not remain to “blog”
can you help?

Sumit December 24, 2012

I did what you said.
but when someone requests ‘’
it gets redirected to ‘’