Moving site from root to subfolder
-
Hello,
I have a site that is installed as usual at root folder of server and using my account’s primary domain.
I wanted to move it to a subfolder in order to have a clean folder structure at server and tried the first method from here without success.
Done several tests with Method 1 and always got 404 errors after trying to navigate away from the homepage. Also changed the WordPress Address (URL) in WP settings to point to the subfolder but also without success.
Is there something else worth trying?
Thanks.
-
You can move your site by following this guide: https://wordpress.org/documentation/article/moving-wordpress/#moving-directories-on-your-existing-server
Thanks but this contradicts the other page that is specifically drafted for my case when wanting to move from root to subfolder.
Giving WordPress Its Own Directory
This new page you suggest is mainly for changing existing folders/subfolders and not for moving from ROOT to SUBFOLDER when a site is the primary of the hosting account. This move needs a new .htaccess at root.
The doc you linked to is for keeping WordPress files in a subdirectory while still loading WordPress from the domain root. So, the files would be at example.com/blog/ but the blog would continue to be viewable example.com.
If you want to move WordPress to a subdirectory and serve it from there (the blog would be viewable at example.com/blog/) then follow the doc I linked to.
-
This reply was modified 2 years, 8 months ago by
James Huff. Reason: typo
Sorry, I’m a bit confused here. Let’s try again:
I have a host with the primary domain example.com.
WP files are currently installed as usual by default at root of /public_html/.
I want to move those files at /public_html/subfolder/ and load them from there when visitors type example.com as currently.Ok, then the doc you’re referring to is the right one.
Once you’ve done all of the steps listed, if you’re still seeing the 404s, try re-saving your permalink structure at Settings > Permalinks in your Dashboard. If WordPress cannot automatically edit the .htaccess file, it will provide manual instructions after saving.
Thanks, tested this but still getting the same 404 errors.
Verify all the files and folders still have the correct owner and permissions as they did before. Depending on how they were moved, owner and permissions can change.
Do you still have the initial .htaccess file now in the subfolder installation? I think it could conflict with the new root .htaccess the doc instructed you to make (unconfirmed). Try renaming the .htaccess in the subfolder installation.
You did not alter the site and home URL settings did you? The settings should have no subfolder, just the domain with its https protocol as it was before.
It’s possible your host has its modSecurity configured in a way where it’s unhappy about subfolder installations. Its configuration may need to be adjusted. It’s likely your host will need to do this for you.
Another way to have a subfolder act as domain root, instead of the suggested .htaccess rules, is to use VirtualHost to set things up. It’s unlikely you can directly edit your VirtualHost files. Typically there’s a way to assign a subfolder as the domain’s root through your hosting UI. This varies from host to host. Check your host’s knowledge base or ask their tech support for specific instructions.
You are both right, my bad!
Permissions and htaccess files were correct but I had previously modified the WP URL to point to the subfolder for testing and I forgot to revert back to the website’s URL, the same as WP URL. Sorry about that.
I simply edited those settings back to their initial values and also re-saved the permalinks and everything works fine again. The htaccess at root remained the same as the one I uploaded that was created based on the WP page above and the original one is the same as initially at the subfolder. I mean the fact that I resaved the permalinks didn’t modify any of them – at least as far as I can see.
Thanks to both of you for your patience and assistance.
PS: I think the re-saving permalinks procedure is key to this process and should be added in the original WP page as a recommended step.
I’m glad it was an easy fix in the end!
You actually don’t need to save permalinks, but you do need to load the permalinks screen when the URL is changed. That’s mentioned in Method II where the URL changes. You were thinking you had Method I where the URL remains unchanged. In that case loading permalinks screen would not be necessary. As it turns out, your URL did change so your process should have been more like Method II. Maybe you didn’t exactly follow the steps outlined, but you eventually hit the required high points.
Thanks for this but no, I don’t think I followed any of the points at Method 2. In fact, those instructions are very confusing and it is still not clear to me which method fits best the case of “moving primary site from root to subfolder“. My understanding is that Method 2 is only when the Site URL changes, not the WP URL. In my case, only the WP URL changed so only Method 1 only should apply.
My mistake was to change the WP URL, thinking that this was necessary anyhow, and that seems to have caused the 404 errors. When reverting this URL back to its initial value everything worked again.
And this is a second confusion here as the change of WP URL is recommended in all WP docs in case you change your WP installation’s location. I thought I had to change this anyhow but there is no mention about it at this page with the 2 methods.
-
This reply was modified 2 years, 8 months ago by
The topic ‘Moving site from root to subfolder’ is closed to new replies.