Wordpress Gets 404 Not Found Error When Entering Address

19,449

When migrating from one host to another, you have to change the following two settings in the wp_options table either via phpmyadmin or equivalent tool, or even via sql commands. The entries to modify are listed by option_name:

  • siteurl
  • home

So for my MAMP install, I have:

option_name    option_value
siteurl        http://localhost:8888/my_dir
home           http://localhost:8888/my_dir

You will need to substitute your port number where I have ":8888".

So now here is the kicker. If you attempt to connect to your local site BEFORE changing the entry, wordpress will send you a 301 redirect (permanent) and your browser will cache that. You have to clear your cache to reset this. (refresh will not work). Depending on your browser, you might have to flush the cache and close and re-open the browser. (See: How long do browsers cache HTTP 301s?)

A mysql update would be similar to: update wp_options set option_value = 'http://mydomain:1234/my_dir' where option_name = 'siteurl' OR option_name = 'home';

where:

  • mydomain is your domainname,
  • my_dir is the directory of your wordpress,
  • 1234 is your port
Share:
19,449
Ken Shoufer
Author by

Ken Shoufer

Hello, I'm a technology geek looking to upgrade my programming skills.

Updated on July 22, 2022

Comments

  • Ken Shoufer
    Ken Shoufer almost 2 years

    I ran into a 404 not found error when trying to access a local Wordpress installation. I am migrating a working Wordpress installation from my hosting account where I set up the WordPress site. After downloading all the files into the WWW folder of my WAMP installation, I imported the SQL file from the server and imported this file to recreate the Wordpress database on my local machine.

    Once completed, I tried to access the Wordpress installation by typing (((http:)))//localhost:8080/wordpress1/. I got a 404 not found error and the address at the top of my browser changed to localhost/wordpress1/. I used parenthesis to stop this editor from making the address a link

    My Wp-config.php settings are: define('DB_NAME', 'wrd_okm5cj2a6c');

    /** MySQL database username */ define('DB_USER', 'root');

    /** MySQL database password */ define('DB_PASSWORD', '');

    /** MySQL hostname */ define('DB_HOST', 'localhost');

    My httpd.conf setting is: Listen 8080

    When I download a copy of Wordpress from the Wordpress site, it works fine. Do you have any idea what could be wrong?

    Ken