Migrated WordPress Site – Homepage Works, All Other Pages/Links Fail

KB ID 0001126 

Problem

I’m in the process of migrating the site back to its original VPS now that the site re-write and redesign has been completed. I used a plugin (UpdraftPlus) to backup the site, and its database, and then restored it to the new server. After the restore I connected to the new server and there was the site in all its glory 🙂

However, every single link I clicked gave me a;

Not Found

The requested URL {Path} was not found on this server

Solution

I struggled with this for a long time, internet searches all said, this is common, it’s because WordPress needs to update its ‘permalinks’, and it needs to write some code to the .htaccess file to do this.

WordPress will add the lines it needs, if you go to Settings > Permalinks, enter your setting, and click save. If it can’t write to the .htaccess file, then it will tell you and show you the code that needs adding, if that happens you have a permissions problem and WordPress has not got the rights to update the .htaccess file.

After much trial and error I deduced permissions were ok, and so was the .htaccess file and the permalink settings.

My problem was the mod_rewite module was not enabled for my website, and even though I’d got WordPress set up correctly Apache web server wasn’t letting the rewrite happen.

On my web server (CentOS7) I needed to edit the http.conf file. (I’m using nano, substitute vi for nano, if you don’t have it installed).

[box]

nano /etc/httpd/conf/httpd.conf

[/box]

Locate the section, that is for the directory /var/www/html, and edit the AllowOveride so that it is changed from None to All.

(WARNING: there will be a few AllowOverrides, change the correct one).

Save and exit the config file, then restart Apache

[box]

/sbin/service httpd restart

[/box]

Related Articles, References, Credits, or External Links

NA