Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Medua Okonta
Medua Okonta
8,808 Points

WP migration problem - Too many redirects/can't login to WP admin

I've been following along with the How to Migrate a Local WordPress Site to Live Server and came across a problem around the 8 mins 25 sec mark.

I edited my WP config file and uploaded it along with the rest of the WP files. I also uploaded the mysql database through phpMyAdmin.

Once i tried to test the site i got an error message "The page isn't redirecting properly". I then, mistakenly, logged in to the admin area and in the Settings > General tab I deleted the localhost part of the URL. Now I'm unable to log back in to the WP admin area.

I've tried adding:

update_option('siteurl','http://example.com'); update_option('home','http://example.com');

To my themes function.php file but this didn't work.

Has anyone got an idea of how to fix this?

8 Answers

Art Skupienski
Art Skupienski
7,080 Points

Hi Medua,

You can still edit necessary Wordpress settings in your database. You will need to edit your WP_options table. Changes you have made in your WP admin went to your database. So no need to change any php files. Rather than login to your MySQL panel and find table called wp_options and make sure your site url has localhost/your-web-folder. Update_option mey not help as you could change something else too. Pay attention to your wp_options table and add necessary changes in order to fix redirections issue.

Medua Okonta
Medua Okonta
8,808 Points

Hi Art,

The wp_options site url is already http://localhost/example.com. I'm still unable to log in to WP admin.

Art Skupienski
Art Skupienski
7,080 Points

Double check your wp_options table. There is more settings to check there and your htaccess file?

Whenever you issues like this check your Apache error log. Let me know if you will still struggle.

Good luck! :-)

Medua Okonta
Medua Okonta
8,808 Points

I've found and changed both site url and home options. Still no change.

Art Skupienski
Art Skupienski
7,080 Points

If you having issues with online site you shouldn't have any localhost connection.

In the box for Site address (URL): change the address to the new location, which should match the WordPress (your public site) address (URI).

Art Skupienski
Art Skupienski
7,080 Points

What sort of server you use for your website? It could be many things that cause your problem, like: plugin settings, damaged database.On some servers it would be better to install WP inside subdirectory then redirect to this subdirectory in htaccess file. NOTE: htaccess has to be in main directory

Medua Okonta
Medua Okonta
8,808 Points

I'm hosting through Dreamhost. I've tried disabling all of the plugins but the problem persists. I've also gone thought the Changing The Site URL codex and still I can't find a solution.

Art Skupienski
Art Skupienski
7,080 Points

In order to help you I will need more details from you.

  1. Whats' in your htaccess file? Have you named it .htaccess and have it in your main directory?
  2. Do you have your website installed in subdirectory?
  3. Do you have it on domain/subdomian?

NOTE: There is more than one method to change your WP site url: http://codex.wordpress.org/Changing_The_Site_URL Pay attention to your domain name when you do update of your site url in wp_options table or via PHP. Check carefully your .htaccess file.

Medua Okonta
Medua Okonta
8,808 Points

I've managed to login to the admin area using the relocate method but now when i try to navigate to settings (or any other option) it redirects me back to the login screen.

Medua Okonta
Medua Okonta
8,808 Points

My .htaccess file looks like this:

BEGIN WordPress

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase /studiomed.co.uk/ RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /studiomed.co.uk/index.php [L] </IfModule>

END WordPress

The site is installed into it the primary domain in the main directory

Art Skupienski
Art Skupienski
7,080 Points

You should play a bit with your htaccess settings to make it work.

This basic htaccess setup for main directory/domain WP installation:

BEGIN WordPress

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

END WordPress