Missing htaccess when migrating WordPress sites
Hi everyone, thanks in advance for any help.
I'm new to Linode after decades of using shared hosting with cPanel, and following this guide to migrate a bunch of WordPress sites to Linode: Set Up Apache to Run Multiple WordPress Sites on a Single Linode.
Unfortunately, when I get through the process, while the sites load, everything but the home page returns a 404 (and it's a 404 served by Apache/2.4.41 (Ubuntu) Server at example.com Port 80, not by the WordPress app).
When I try to dig in, it seems the the issue is that an .htaccess file was never created.
Looking back at the instructions, that should happen towards the end, as a result of the Configure Apache Virtual Hosts steps. But I can not figure out why .htaccess is missing.
- Verifying that rewrite_module is enabled
- Repeating the process (enabling the site, reloading Apache)
- Deleting the example.com.conf files from /sites-available/ and /sites-enabled/ and then repeating the process again…
Would could I be doing wrong? Or not doing right?
ps. Also wanted to add that the sites use Cloudflare. Thinking that there might be some kind of conflict going on with Cloudflare, I tried turning on Development Mode, as well as just pausing the site on Cloudflare entirely. And I disabled two plugins that I use to make them function with Cloudflare, SSL Insecure Content Fixer and Cloudflare Flexible SSL.
I presume you're copying the site files from your previous shared hosting site? How are you doing that? Depending on how you do the copy, it's possible that "hidden" files (on Linux, files that begin with a . are treated as hidden) like .htaccess might not be copied.
When you create a WordPress site using that guide , the
.htaccess file isn't automatically created. This is something you'd need to manually create. You may do so with the following command:
This is further highlighted in this post from our community site:
After the file's created, you may write in the configurations that you need.
You may also refer to this guide for more details on How to Set Up the htaccess File on Apache.
@bcoleman Thanks. I'm using completely fresh WordPress installs and not copying over any WordPress files. I'm migrating the databases cleanly by exporting in phpadmin on the old host and then importing with phpmyadmin after installing it on Linode, which was also a fun adventure. I copied over just plugins, themes and uploads from wp-content and had to change the user/group ownership.
In short - I'm not trying to copy over .htaccess from the previous host. I'm trying to have it installed on Linode.
@dcortijo Thank you for the answer, but I don't think it's correct.
The guide does create an .htaccess file. I've been doing this for multiple sites and some sites have .htaccess while others do not. So clearly there's something that I am doing incorrectly in some cases but correctly in others.
I'm aware that I can simply create a file called .htaccess in the correct directory, but I don't know if it will actually act like the other .htaccess files that have been correctly created via the above process.
I've finally figured out what I was doing wrong.
Besides following the steps in the guide, I actually needed to log into WordPress and make a change in /wp-admin/ > Settings > Permalinks.
Once that is done, .htaccess is generated automatically for each site.