• Resolved C W (VYSO)

    (@cyril-washbrook)


    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 browsing https://mysite.com instead of https://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 to https://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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Which .htaccess is this?

    Have you tried putting that “^wordpress/…” rule above the normal WordPress ones? .htaccess rules execute line by line. Order does (sometimes) matter.

    Thread Starter C W (VYSO)

    (@cyril-washbrook)

    Yep, worked that out a couple of hours after posting! It’s now working fine.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Subdirectory install with access from root’ is closed to new replies.