Redirect Subdirectory From Old Domain to New Domain Root for WordPress

We can take for example that we are migrating an old website and what to migrate this onto a WordPress website. To do so, we add the following code into the old website’s .htaccess file:

### BEGIN Redirect /example subdirectory to
Options +FollowSymLinks
RewriteEngine On
Redirect 301 /example
### END Redirect /example subdirectory to

You will have to upload this into the folder where you would like all the contents of that subdirectory redirected to the new domain root. In the example, is the new domain root, and /example is the subdirectory of the old website.

And once that is done, you can check this out by going to HTTP Status website and test a few URLs of the old website’s subdirectory. It is okay if they go to 404. But you want to make sure that the contents redirect to the new domain.

For example, the old domain may have a webpage which will be redirected but end in a broken link at the new domain

Now is the other half of the process. What we will do are the following:

  • Log into the new domain’s WordPress CMS
  • Install the plugin Redirections
  • Within the Redirections plugin, create redirects from the source /shop.htm to the destination. The destination can for example be
  • Test that it is working, using

That should get it working properly!

Bonus: Redirect all .htm or .html pages to homepage, using Redirections plugin

Using the Redirections plugin in WordPress, you can add the following:

  • Create a new redirect
  • Enable the Regex option
  • Set (.*)\.html?$ as your Source URL. This will match all URLs ending in .htm or .html
  • Set your Target URL to whatever of your WordPress webpages
  • You will want to make sure that this in the last Position of your redirections Group, so as high as possible.

Happy htaccess coding!

WP Feedback

Dive straight into the feedback!
Login below and you can start commenting using your own user instantly