• Hi everyone.
    I want to move my WordPress installation to a subfolder, to be able to host other stuff on the server as well. I now have it installed in the webservers root directory. I want to move it to a subfolder, and I will then redirect the URL pointing to the site, so that the new folder is the document root for that domain. I have read this codex article, but it seems that they keep the URL pointing at the old (root) directory, and therefor they keep some files in that directory. What do I have to do if I change the URLs document root as well? Do I have to do anything at all, or can I just copy all the stuff and have the URL point there? Database access credentials and all that stuff will of course stay the same…

    Thanks for helping,
    Gasp0d3

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    I want to be sure I understand your plan.

    1. You have two or more domains that all lead to your public_html or whatever public root folder. Let’s call them foo.com and bar.com.
    2. Your WP installation is currently installed in public_html root and the WP and site addresses in settings specify bar.com
    3. You want to move the entire WP installation to public_html/bar and enter a public_html/.htaccess redirect for bar.com requests to go to public_html/bar such that a request for just bar.com opens the WP front page.
    4. foo.com continues to lead to non-WP files in public_html

    If that’s all correct, then the bit in the Codex about leaving WP files in root do not apply. That method will work to the same end, but I find it rather confusing. I’ve used the above approach many times and find it more intuitive.

    Simply copy all things WP complete to public_html/bar, maintaining the same standard WP folder structure, such as public_html/bar/wp-content/themes/twentysixteen. This includes the .htaccess file containing permalink rewrite rules. However, other rules probably need to remain in root unless they are specifically for WP. You may need to split the file contents.

    In the public_html/.htaccess file, enter the rewrite rules to get bar.com requests to public_html/bar. Use relative rewrites (no domain name in the target). There’s no need for any 301 redirect response, external devices will never know anything was moved. Don’t forget to include a condition rejecting requests containing the /bar/ sub-folder otherwise you will get infinite redirects.

    That’s all. You may have to log in again, but everything should work as it did previously. If there’s any departure from my enumerated assumptions above (other than the actual domain and folder names) let me know and hopefully I’ll know how to compensate.

Viewing 1 replies (of 1 total)

The topic ‘Moving WordPress to subfolder, keeping it in the document root’ is closed to new replies.