Files on Localhost, Database on Server

Yes, the 404 is because the local and remote server URLs are different. As a solution:

  • You should set the local domain to be the same as the remote server
  • In wp-config.php connect to the remote DB
  • When you will need to access the remote server you’ll need to update the file hosts and comment out the line with your remote url
    • If your hosts file is updated on start/stop of your local server you can just stop the server and you’ll have acces to the remote

If your domain name is xdirtseries.co.za you should set in vhost the server name and alias to match the domain, so that when you local server is started you’ll see the local version, otherwise your online version.

ServerName xdirtseries.co.za
ServerAlias www.xdirtseries.co.za

And the hosts file:

127.0.0.1 xdirtseries.co.za www.xdirtseries.co.za

This should work 🙂