WordPress installed Subdirectory – Now lots of existing hyperlinks are not working

I installed WordPress in a subdirectory for development – the subdirectory is /site/. When we were ready to go live we followed the instructions here http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory#Using_a_pre-existing_subdirectory_install to make the site live at the root URL. This has worked fine.

However what I’m struggling to fix is that many of the hyperlinks existing in the site now give 404 errors. Some pages redirect, but if they have a parent, then they don’t redirect.



> successfully redirects to mydomain.com/specials


mydomain.com/site/contact-us/request-a-quote/ gives a 404 error.

It should redirect to mydomain.com/contact-us/request-a-quote/ but it doesn’t.

It seems any previously built hyperlink that points to a page which has a parent page, ends up as a 404 error.


1) We could use a Search and Replace option to remove /site/ from each URL … however this will break all images at the same time.

2) We could manually update the links … but there are way too many.

3) Is there an .htaccess solution?

I have tried to solve this by adjusting the .htaccess file to redirect URLs with /site/ in them to the root directory. However if we do this we need to exclude wp-admin, wp-content, wp-includes, /site/index.php and others. Whatever I have tried so far fails.

And there is nothing in the official documentation about what to do with existing hyperlinks when moving changing a subdirectory install to displaying at the root domain. (And the really weird thing is that I tested this when I first when live with the site, and all the redirects worked fine, including the ones with parent pages, but it has since stopped working, and I don’t know why).

Here is my .htaccess contents:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /site/
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site/index.php [L]


# END WordPress

Can someone provide lines of code that will work?