I have a WP 4.0 site that has been installed at:
mydomain.com/site
It's been there for many years, so there are lots of links from around the web pointing to it.
As part of an overhaul I am doing, I would like the wordpress site to be accessible at the root URI: mydomain.com (and www.mydomain.com), without "/site" needing to be on there.
I found articles that told me about copying the index.php and .htaccess to the root, and changing the site URI in the wordpress settings. But the instructions I've come across always seem incomplete, as they seem to assume it's a new site with no existing links to deal with in order to avoid lots of 404 errors.
So the issue I now have is that the old links generate 404 errors (because they have "/site/" in them. Images also fail to display, as they are obviously stored in the DB with "/site/" in their URI.
I have been trying to figure out a failsafe way to use .htaccess rewrite rules to redirect everything (except, wp-admin, I suppose?) from /site to /
In case it's helpful, my existing permalink structure is
mydomain.com/site/%postname%-%post_id%/
Any suggestions on the best way to go about this would be greatly appreciated. Thanks.
RewriteRule ^site/ /$1 [R=301,NC,L]
in your .htaccess should work. All requests containingsite/
will be redirected to the same URL withoutsite
in it – permanently, without considering case and without following any other rules after that./site/
or the root, or both? If either case, is it necessary to have RewriteBase, and if so, should that be/
or/site/
? Is there a simple way to test if mod_rewrite is even firing?