posted from http://feedproxy.google.com/~r/tipsandtricks-hq/~3/2cmZpogQc6s/how-to-fix-wordpress-site-not-working-on-localhost-after-port-change-9373

If you have installed WordPress on localhost (example: using XAMPP) and then later you need to change the Apache’s HTTP port number, you will find that the existing WordPress installs will stop loading. It will auto redirect to the URL with the old port number and fail to load. Trying to load the WordPress install will result in a 404 error.

In this tutorial I will show you how you can easily rectify this issue so you can use the existing WordPress installs after a port change (no need to install WordPress from scratch).

Little Background

I have a few localhost WordPress installs that I used using Apache HTTP port #81. I needed to change the port #80 so I could create a new localhost WP Multi-site install (multi-site installs only work on port 80). When I changed the Apache’s configuration to use port 80, all my existing WordPress sites stopped loading. this tutorial contains the steps I took to resolve the issue.

The Main Reason for the Existing WP Site to Not Load

The reason the site is not loading after the port change is because of the site URL value (that contains the old port number) in the wp_options table. So we are going to update that value to the new port number.

Update the WP Database Table

Here is how you can fix it by updating the port number value in the database:

  • Access PHPMyAdmin tool. http://localhost:80/phpmyadmin and log in.
  • Click on the WordPress site’s database (the one that is not working).
  • Click on the “SQL” tab.
  • We are going to execute a DB query to search and replace the old port value.
  • Execute the following query:
UPDATE `table_name` 
SET `field_name` = replace(field_name, 'old_text', 'new_text')

In my case, the exact query that I executed is the following (I was going from port 81 to the default port):

UPDATE `wp_options`
SET `option_value` = replace(option_value , 'http://localhost:81', 'http://localhost')

That should do it. Check the WordPress site and it should be accessible now.

comments