Subdirectory install with access from root
-
I’m attempting to run WordPress from the root while keeping it in its own subdirectory. I’ve essentially followed the procedure under “Moving a root install to its own directory” in the Codex, the only difference being that my core files were already in the subdirectory, which makes Step 6 unnecessary.
This has worked exactly as intended. Now, the
/wordpress
bit of the URL is stripped out and it looks to the end user as though they’re browsinghttps://mysite.com
instead ofhttps://mysite.com/wordpress
.Problem: I don’t want all the old links to break. If an external site linked to
https://mysite.com/wordpress/2011/06/an-article-slug
, they’re now going to get a 404 page. I’d much prefer that they get automatically (301-)redirected tohttps://mysite.com/2011/06/an-article-slug
, which is the new location of the file.I’ve tried to insert a rule into the .htaccess files [N.B. the procedure in the Codex means that there are now two .htaccess files: one in the root and one in the subdirectory] to bring about this behaviour, but it is still failing to do the redirection (and is therefore delivering 404s). Here’s the .htaccess:
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /wordpress/ RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /wordpress/index.php [L] RewriteBase / RewriteRule ^wordpress/(.*)$ /$1 [R=301,NC,L] </IfModule> # END WordPress
The last two lines before the end of the
if
statement are my attempt to get the redirection to work.
- The topic ‘Subdirectory install with access from root’ is closed to new replies.