Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress redirect to subdirectory - wp-admin forwards to wrong login url

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.

like image 534
smrkem Avatar asked Mar 13 '14 19:03

smrkem


1 Answers

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

like image 166
Virgílio Santos Avatar answered Oct 16 '22 02:10

Virgílio Santos