WordPress admin console redirecting to wrong URL
-
Hello!
Hopefully someone can help with this issue.
I recently moved WordPress to its own folder and used the instructions in https://codex.ww.wp.xz.cn/Giving_WordPress_Its_Own_Directory (used Method I which is for moving to a different folder but not changing the URL) to move WordPress to its own folder.
The website itself works, but if I access http://www.xyz.com/wp-admin then it sends me to http://www.xyz.com/wp-login?redirect_to=http%3A%2F%2Fwww.xyz.com%2Fwordpress%2Fwp-admin%2F&reauth=1
Notice the redirection is to the URL with the subfolder, which should not happen AFAIU.
The issue is that then if I log in, then it sets the cookie to the path wwww.xyz.com/wp-admin, so it does not work with http://www.xyz.com/wordpress/wp-admin and hence when it redirects back it does not actually work and it then just shows the log-in screen again.Debugging into the PHP code a bit, it seems that the redirect URL is built from PHP’s superglobal variable $_SERVER[‘SCRIPT_URI’], and that this URI is populated (by Apache I assume) to be http://www.xyz.com.au/wordpress/wp-admin.
So it seems that Apache is not giving PHP the correct SCRIPT_URI?Strangely enough, when I go to http://www.xyz.com/wp-admin/ (with the trailing slash) then the SCRIPT_URI is populated with http://www.xyz.com/wp-admin/ (i.e. the subfolder is not added).
I am not really sure why this is happening.Below is my .htaccess file, which I constructed according to the guidelines in https://codex.ww.wp.xz.cn/Giving_WordPress_Its_Own_Directory:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP_HOST} ^(www.)?xyz.com$ RewriteCond %{REQUEST_URI} !^/wordpress/ RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /wordpress/$1 RewriteCond %{HTTP_HOST} ^(www.)?xyz.com$ RewriteRule ^(/)?$ wordpress/index.php [L] </IfModule>[Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]
PHP version is 5.3
The topic ‘WordPress admin console redirecting to wrong URL’ is closed to new replies.