Redirect loop to wp-admin or wp-login.php
I built a fast WordPress site locally using MAMP and then checked it into the SVN repository. Then I tested this on my development server.
I haven't changed anything except to run the tool 's find and replace script from Interconnectit to update the site url in the database on the server.
Initially I got 500 server errors. Checking the logs I found that this "SoftException" was due to being index.php
writable by group - the permissions were 664. No problem - quickly changing the permissions to 644 sorted this out. So now the front side worked.
However, oddly enough, the admin side of the site didn't work. It just created an endless redirect loop across 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 file. Nothing weird ... still works fine in place.
So what's going on?
source to share
Checking the permissions wp-login.php
showed that they were also set to 664 - the same permissions that caused the denial index.php
and caused the 500 server error.
I changed the permissions from wp-login.php
to 644 and hey presto the WordPress login page appeared.
But on login, another redirect loop. So again looking at /wp-admin/index.php
, the permissions were 664 and not 644.
Eliminating them led to problems with the following files in line - the dashboard was the correct confusion. One by one, 664 to 644 fixed the problems (/wp-admin/load-scripts.php,/wp-admin/load-styles.php).
So it became apparent that changing permissions recursively was the only way to figure it out.
My UNIX isn't exactly point-to-point, but it seems to work (works with Mac OS X Terminal). I ran it from the root of this WP installation.
find . -type f -perm 664 -print -exec chmod 644 {} \;
Maybe the best command, but I understand it means "find all 664 files and change them to 644".
He fixed my problem.
source to share
For some reason / wp -admin / path causes a redirect loop, but / wp -admin / index.php doesn't. So we can use .htaccess to redirect / wp -admin / path to / wp-admin / index.php by adding the following line to your .htaccess file after the "RewriteBase /" line like this:
RewriteBase /
RewriteRule /wp-admin/ /wp-admin/index\.php [L,P]
It worked for me like this. Your final .htaccess will probably look like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule /wp-admin/ /wp-admin/index\.php [L,P]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
source to share
If your web server is nginx, you may need to check your nginx config file. If there's
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
source to share
If you are using Cloudflare, you can try adding this to the TOP of the wp-config.php file:
define('WP_SITEURL', 'https://www.example.com');
define('WP_HOME', 'https://www.example.com');
define('FORCE_SSL_ADMIN', true);
define('FORCE_SSL_LOGIN', true);
if(isset($_SERVER['HTTP_CF_VISITOR']) && strpos($_SERVER['HTTP_CF_VISITOR'], 'https')){
$_SERVER['HTTPS']='on';
}
It is important that you add it to the beginning of your wp-config.php file, otherwise you will receive the error "Sorry, you cannot access this page."
Courtesy of: https://www.meltajon.com/dev/wordpress-wp-admin-redirect-loop-with-cloudflare-ssl.
source to share
I was getting DoS pages when trying to publish to my WP site. I found advice that changing the permissions in the function.php file to 600 might fix the problem and also add a script snippet to that file. This is the WP help page. I was able to get to the post in different ways. There is still a DoS when I try to open the editor.
source to share
I just needed to clear my redirects. Since I couldn't access Admin, I added this to the top of my functions.php file:
flush_rewrite_rules();
exit;
Saved and updated my place. Then remove the code from your functions.php file and update it again. This did it for me.
I also think it might be a good measure to keep your permalinks.
PS. I think the main problem was coming from topic-my-login as it was being redirected to / login.
source to share
In the sites-enabled folder, you will need to edit the configuration for your site and add multisite redirect rules. For Ubuntu 14.04, you should be able to find the path under / etc / nginx / sites -available
Add the following block to your server block and you can avoid an endless redirection loop.
#Rewrite multisite '.../wp-.*' and '.../*.php'.
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
source to share
In my case, it was an Apache issue DirectoryIndex
. Access wp-admin
was from wp-admin/index.php
, but not from, wp-admin
and was shown ERR_TOO_MANY_REDIRECTS
.
It looks like Apache DirectoryIndex
may not be installed "correctly". Try dumping this at the top of the file .htaccess
:
DirectoryIndex index.php
See the full answer here. Can't access admin panel using wp-admin without /index.php after it
source to share
If you have nginx then check your index configuration as well. As for me, I had a problem: I installed the following:
server {
server_name _;
root /var/www/html;
index /index.php;
}
So, as you can see, I have set index.php with a trailing slash, which means that all rewrite requests will be sent to index.php in the documentro. This is not correct for WP because the wp-admin directory has its own index.php
source to share
The above answers came pretty close to me. In our particular case, someone at some point added some rules to the htaccess file at the root of the site and in the admin folder to block traffic from everywhere except for some white IP addresses (when trying 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>
Whitelisting our IP address in both files fixed the issue.
source to share
I faced the same problem after restoring a backup from another server, it was a promising problem and I solved it this way.
chown -R www-data:www-data /var/www
chmod -R g+rwx /var/www
Where /var/www
is the place to store the website files, replace it with a suitable path according to your configuration, for example /usr/share/nginx/www
<< default Nginx
source to share