WordPress Migration: Getting 404 Errors: Only Home Page works

Home /

The website would work on the home page and I could log into WordPress admin, but if I clicked on any other link it resulted in a 404 error.
The page that is linked to in some of the other answers isn’t the ideal solution. Basically, it turns on AllowOverride to “All” which allows .htaccess files to work. This is great when you are on shared hosting with no access to the apache configuration file, but shouldn’t be used when you are on a host such as AWS, GCP, Oracle, where you have access to the server configuration file.
The ideal solution is to put the information that is in the WordPress .htaccess file into the main apache configuration file. This helps to improve server performance.
1. Solve this problem on Linux Mint 19 / PHP Version 7.4.19-0ubuntu0.20.x by changing:

Options Indexes FollowSymLinks
AllowOverride None
Require all granted


Options Indexes FollowSymLinks
AllowOverride All
Require all granted

in /etc/apache2/apache2.conf.
2. Go to settings->permalinks and click on save button to rewrite flush. And then empty your browser cache. It’ll work hopefully.
3. Sometimes on a new server it’s just the rewrite module missing from Apache config.
sudo a2enmod rewrite
sudo service apache2 restart