0

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 with 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?

  • First thing to try is go back and use a database migration plugin. Just search-and-replace is likely to cause issues because WP stores so much serialized data. Second thing to try: delete .htaccess, log in, and visit your permalink settings page to regenerate the default WP .htaccess. Then make sure to open an Incognito window or clear browser cache & restart browser to check if it's fixed. – WebElaine Nov 13 '17 at 19:34
  • Your local url is potentially spelled incorrectly, depending on how you did it... Unless that's the way it's supposed to be.. website should have the I and S switched around: local.website.com Probably not your issue, but figured I'd point it out anyway. – socki03 Nov 13 '17 at 19:56
0

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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.