Search code examples
wordpressapache.htaccesslamp

How to move wordpress website from hosting account to localhost


I'm getting 404 error while accessing relative paths on Wordpress website copied from hosting and deployed locally as Apache vhost.

Local website is basically git clone of the existing remote website.

The following steps were performed to make it work:

  • DB urls were searched and replaced using wp-cli to be http://local.webiste.com

  • VHost configured according to apache documentation.

  • /etc/hosts modified.

So website can be accessed successfully via http://local.website.com.

Media in http://local.website.com/wp-content/uploads/2017 can be viewed successfully.

Though, accessing a Wordrpess page identified by /relative path (relative to current domain/site) causes "The requested URL /relative/ was not found on this server" error.

I'm using the same .htaccess from the remote public_html folder.

How to achive equivalent to hosting behaviour for local vhost website?

Is .htaccess, apache2 configuration, vhost configurations should be changed?


Solution

  • The solution was to allow using .htaccess in /etc/apache/apache2.conf by changing from AllowOverride None to AllowOverride All. More about it here

    So that section related to my local website now looks like:

    <Directory /var/www/local.webiste.com/public_html>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
            Allow from 127.0.0.1
    </Directory>