Back to Top

How to move WordPress from subdomain to subdirectory?

To migrate Wordpress from subdomain to subdirectory

Most of the bloggers keep blog into sub-domain but get the more SEO benefits and increase page rank of the site, sub-directory is good rather than sub-domain. One more reason is inbound links to sub-domains are preserved differently to links which point to the root directory and Sub-domains are less trusted than sub-directories in Google.

However, If you move WordPress blog or forum from sub-domain to sub-directory, it’s easy to move blog to new location but main issue is your blog URLs are submitted into Google and other search engines so until newly generated sitemap not submitted to Google, user will get “not found” link from Google and which affects your site popularity, backlinks and traffic from search engines too.So, It’s necessary that no broken links or 404 errors found.

Read: Introduction to Transient API in WordPress

Today I am going to explain about how to move the WordPress blog to a new sub-directory from sub-domain with considering SEO benefits so visitors will not get “Not found” link till Google does not upgrade links into search engine.

First of all, Backup database and copy WordPress folders and files into new location and set URLs in the database.Then update permalink structure from admin.

Next is the permanent redirection of URL from sub-domain to sub-directory. To move all old previous sub-domain URL’s to the new sub-directory structure, You need to write below .htaccess code which automatically redirects to sub-directory rather than manually adding redirection code for each and every URLs.

RewriteRule ^(.*)$ http:/ //$1 [R=301,L]
RewriteRule ^(.*)/([a-zA-Z0-9_-]+)$ http:/ //([a-zA-Z0-9_-]+)$1 [R=301,L]

Last but not the least, update your XML sitemap and make sure old URL’s are removed from Google search engine otherwise it leads to the duplicate content issue.

Also Read:
To add new URL rewrite rule in WordPress

I’m hoping that you’ve found this article helpful. Don’t hesitate to use this code in your WordPress projects and post your comments if you need help. As always, thanks for reading. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.

Comments (1)

  1. Hola,

    Sinceramente hemos encontado tu entrada del blog verdaderamente útil.
    Esperemos que siga redactando este tipo de entradas! Volveremos
    en breve a su blog para ver las novedades

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts


Posted on 2 years ago


Learn about the Docker and how it works

Posted on 3 years ago


How to connect to MySQL database using PHP

Posted on 6 years ago


Post via e-mail in WordPress

Posted on 7 years ago


Hello world

Updated 1 month ago

Nick Carter

In depth Understanding of Laravel Core

Updated 3 months ago


ECMAScript 6 New Features – 2

Updated 1 year ago


The Reader’s Poll – June 2015

Posted on 4 years ago


The Reader’s Poll – August 2014

Posted on 5 years ago


The Reader’s Poll – June 2014

Posted on 5 years ago


The Readers’ Poll – May 2014

Posted on 5 years ago


The Readers’ Poll – August 2013

Posted on 6 years ago