Redirect loop on wp-admin or wp-login.php

2019-03-30 08:27发布

I put together a quick WordPress site locally using MAMP, then checked it into an SVN repo. I then checked it out on to my development server.

I didn't change anything except to run the search and replace tool script from Interconnectit to updated the URL of the site in the database on the server.

Initially, I got a 500 server error. Checking the logs, I discovered that this "SoftException" was because index.php was writeable by group - the permissions were 664. No problem - a quick change of permissions to 644 sorted that. So now the frontside was working.

However, strangely, the admin side of the site did not work. It just produced an endless redirect loop in all browsers.

Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects.

Nothing has changed since the local development version. The htaccess file is just a standard WordPress one. Nothing weird... still working fine locally.

So what's going on?

14条回答
可以哭但决不认输i
2楼-- · 2019-03-30 09:01

if your webserver is nginx,you may need check the configure file of your nginx. If there is

if (!-f $request_filename){
    rewrite ^/(.+)$ /index.php?$1& last;
}

Replace these lines with

try_files $uri $uri/ /index.php?$args;

See also Nginx Pitfalls , WordPress wiki page on nginx

查看更多
一纸荒年 Trace。
3楼-- · 2019-03-30 09:02

The above answers got me pretty close. In our particular case, someone at some point had added in some rules to the htaccess file in the site root and in the admin folder to block traffic from everywhere except some whitelisted IPs (when attempting to access wp-admin).

Example:

<Files wp-login.php>
   order deny,allow
   Deny from all

   # Allow from this IP address
  allow from 123.45.67.89
</Files>

Adding our IP to the whitelist in both files remedied the problem.

查看更多
登录 后发表回答