I’m completely new to WordPress although an experienced web developer and comfortable with system management. I have a working WP site (not developed by me), let’s call it ‘www.mysite.com’ (although that’s not the actual domain name), which is running on a Centos server (shared hosting). I’m trying to set up a copy of it at the subdomain ‘www2.mysite.com’ running on an Ubuntu VPS. I have set up Apache and PHP on this new machine, created a virtual host, and copied over the website directory and pointed the virtual host at it. I have put the following lines at the top of wp-config.php:
define( 'WP_HOME', 'https://www2.mysite.com' );
define( 'WP_SITEURL', 'https://www2.mysite.com' );
I have done a dump of the MySQL database of the original site, replaced all instances of ‘www.mysite.com’ with ‘www2.mysite.com’ (in case of links with absolute host names) and imported. I have also done the same search and replace throughout the theme directory. I have also emptied the cache directory.
So I would now think I have a complete copy of the site, but using the new subdomain. The home page comes up OK, but when I click on any of the links, like ‘https://www2.mysite.com/contact-us’ I get a regular Apache error telling me the page couldn’t be found on the server, not a PHP error. It’s as if PHP is not even involved.
I can access the admin area (https://www2.mysite.com/wp-admin/), if that’s relevant (although had to disable the WordFence plugin to do so).
So what might I have neglected to do in this migration process?
2
Answers
This turned out to be a permalinks issue, as suggested by user18371825, and the culprit was a top level Apache setting in apache2.conf.
AllowOverride None
needed to be changed toAllowOverride All
in the following block:This sounds like a permalink issue. It’s caused by needing to refresh/flush the permalinks after a domain change/migration..
Navigate to
settings -> permalinks
in the WordPress backend and pick your preferred structure (if the selected one is your preferred structure you don’t have to change it) and save.