6
votes

I moved a Wordpress site to a new server. The site is installed in a subdirectory and the .htaccess in the root forwards to it like so:

 RewriteEngine On
 RewriteCond $1 !(^wpfolder/)
 RewriteRule ^(.*)$ wpfolder/$1 [L]

I've changed the site_url and home entries in the wp_options table in the database. Everything is working fine - except if I visit site.com/wp-admin to login - it redirects to the login page like so:

site.com/wp-login.php?redirect_to=http%3A%2F%2Fsite.com%2Fwpfolder%2Fwp-admin%2F&reauth=1 (notice the 'wpfolder' in the redirect_to value)

When I enter the correct username and password, nothing happens and I get the login box again. I can log in no problem by visiting site.com/wp-login.php - but I'd really like to solve this redirect problem if possible.

2
Same problem here, trying to figure out how to make it work... it seems it should be prevented in the rewrite rule (something like: on redirect, use original url) - Virgílio Santos

2 Answers

2
votes

I found a solution that worked for me. Update the site url to site.com/wpfolder

if you are having problems doing that, you can put define('RELOCATE',true); on you wp-config.php file and it would do it for you. The admin and login links will be site.com/wpfolder/wp-admin but on the site itself the url are all relative to the root (site.com/about) and I think it is the correct behavior of this configuration

Hope it help

0
votes

This problem often occurs when moving WordPress.

I use a plugin called duplicator when moving sites. It's great for moving test sites to their live server and much more.

Just search Duplicator inside the plugins section of the back end.

https://wordpress.org/plugins/duplicator/

The plugin takes all files and also the database as a backup for you to install on a new server or even just move to a different directory.

When you have downloaded the files duplicator provides you can upload installer.php and backup.zip to the new server or directory.

Run installer.php and enter the new database and website details in the prompts.

Let the plugin do it's stuff.

After it is complete there will be no problems with any area of the site.

Although it seems like a long process it rarely takes more than 5 minutes depending on how many files the WordPress build contains.