.htaccess – Removing a subdirectory from the URL

So I have a site currently located in a subdirectory, like so:


We are moving this site to a new server, and it will no longer be in a subdirectory. However, we need all the old URLs to still work, so for example if someone tries to go to http://example.com/wp/contact, it will rewrite to http://example.com/contact.

This seems like it should be simple. I’ve tried this:

RewriteEngine on
RewriteBase /
RewriteRule ^wp/(.*)$ /$1 [R=301,NC,L]

Which almost works, except it causes all the WordPress permalinks to 404 – so http://example.com/contact won’t be found even though it should be the correct URL. Does anyone know why this is happening?

Read more here: .htaccess – Removing a subdirectory from the URL

Leave a Reply

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