2

I currently have a website at site.com and have WordPress installed in me website's root folder. My website includes pages like:

  • site.com
  • site.com/page
  • site.com/2015/10/01/post....
  • site.com/login
  • site.com/wp-content/uploads/...

I would like to move all WordPress files into one subdirectory for sanity and NOT CHANGE ANY publicly facing URLs. Other posts here and and the official support thread talk about "Giving WordPress its own directory" but require changing URLs:

Please advise if this is possible.

5

The procedure is thorooughly documented in Codex under Moving a Root install to its own directory.

You misunderstand the point about changing URLs in it, and yes terminology sucks. They only URLs that will change are those that are based on the "WP address". That would be WordPress core, essentially the admin area.

All content URLs are based on "Site address", following this procedure, that will still be the root of your site.

Since you want to retain uploads in place, you can do that by keeping wp-content in the root (splitting it out of core folder) and adjusting configuration for that. See Moving wp-content folder.

1

Okay, here is how it is done:

  1. Move wp-*, index.php, .htaccess to your new wordpress folder
  2. Edit wordpress/.htaccess:

    • Find this line: RewriteRule . /index.php [L]
    • Make it: RewriteRule . /wordpress/index.php [L]
  3. Create a new file in /path/to/www called .htaccess then add this:

RewriteEngine on
RewriteRule ^$ https://www.example.com/ [L]

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^/wordpress/index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /wordpress/$1 [L]
</IfModule>
0

Method for moving Wordpress files to another folder (directory) without changing the Wordpress configuration, i.e. completely transparent to Wordpress :

  1. create a directory where the Wordpress installation will be moved into, e.g. "sitedir"
  2. move the WP installation, inluding .htaccess, into that newly created directory
  3. edit the .htaccess file in the www root directory (likely public_html) and insert the following stances:
    RewriteEngine On
    RewriteBase /

    # redirect to ./sitedir/
    RewriteCond %{http_host} ^example\.com$
    RewriteCond %{request_uri} !^/sitedir(/.*)$
    RewriteRule ^(.*)$ /sitedir/$1 [L,QSA]

    # extra, redirect www.example.com to example.com
    RewriteCond %{http_host} ^www\.example\.com [NC]
    RewriteRule ^(.*) http://example.com/$1 [R=301,L]

Replace "example.com" with your domain en "sitedir" with the name of the folder that WP would be placed in.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.