Infinite Redirect Loop


#1

I’m wondering why my WP Nginx setup is having an infinte redirect loop while I try to access the wp-admin. The frontend works fine, but I’m having issues while I try to access the backend.


#2

@Arjun,

Please give us more details:

curl -I example.com  
curl -I example.com/wp-admin/  
curl -I example.com/wp-login.php

Also provide us your nginx configuration for example.com
Replace example.com with your domain name.


#3

Hello Mitesh,
This is the screenshot of the commands,

This is my configuration for the domain http://hobbymela.com

# WPSINGLE FAST CGI NGINX CONFIGURATION  
server {  
        server_name "~^(?!www\.).*" ;  
        return 301 $scheme://www.$host$request_uri;  
}  
server {  
	  
	server_name hobbymela.com www.hobbymela.com;  

	access_log   /var/log/nginx/hobbymela.com.access.log rt_cache;  
	error_log    /var/log/nginx/hobbymela.com.error.log;  

	root /var/www/hobbymela.com/htdocs;  
	index index.php index.htm index.html;  

	set $skip_cache 0;  

	# POST Requests And Urls With A Query String Should Always Go To PHP  
	if ($request_method = POST) {  
		set $skip_cache 1;  
	}  

	if ($query_string != "") {  
		set $skip_cache 1;  
	}  

	# Don't Cache Uris Containing The Following Segments  
	if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {  
		set $skip_cache 1;  
	}  

	# Don't Use The Cache For Logged In Users Or Recent Commenters  
	if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {  
		set $skip_cache 1;  
	}  

	# Use Cached Or Actual File If They Exists, Otherwise Pass Request To WordPress  
	location / {  
		try_files $uri $uri/ /index.php;  
	}  

	location ~ ^/wp-content/cache/minify/[^/]+/(.*)$ {  
		try_files $uri /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1;  
	}  

	location ~ .php$ {  
		try_files $uri /index.php;  
		include fastcgi_params;  
		fastcgi_pass php;  

		fastcgi_cache_bypass $skip_cache;  
		fastcgi_no_cache $skip_cache;  

		fastcgi_cache WORDPRESS;  
		fastcgi_cache_valid 60m;  
	}  

	location ~ /purge(/.*) {  
		fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";  
	}  

	include /etc/nginx/common/wpcommon.conf;  
	include /etc/nginx/common/locations.conf;  
}  

#4

Its seems like plugin isssue

  
mitesh:~/ $ curl -I http://www.hobbymela.com/wp-admin/\?asa                    [14:41:43]  
HTTP/1.0 302 Moved Temporarily  
Server: nginx  
Date: Tue, 15 Jul 2014 09:12:29 GMT  
Content-Type: text/html  
Expires: Wed, 11 Jan 1984 05:00:00 GMT  
Cache-Control: no-cache, must-revalidate, max-age=0  
Pragma: no-cache  
Location: /wp-admin/?asa&redirect_to=http%3A%2F%2Fwww.hobbymela.com%2Fwp-admin%2F%3Fasa  
X-Powered-By: EasyEngine  
rt-Fastcgi-Cache: BYPASS`  

Please login into wp-admin and disable all plugin and try
For login into wp-admin use http://hobbymela.com/wp-login.php


#5

I can’t even login to the backend. I could actually deactivate the plugins through FTP, then it’ll work fine, which I tried earlier. How could I actually find out which plugin is causing the issue?


#6

Just disable all the plugin and enable one by one to find out which plugin cause the issue.
Also monitor the logs file by using following command

tail -f /var/www/example.com/logs/*


#7

That helped Mitesh. The redirect is caused by WP User Frontend Pro plugin. I’ll open a support thread with them.

Thanks for the help! :slight_smile:


#8

Glad to know your issue is fixed :slight_smile:


#9

Been searching for hours for a fix for this, and finally stumbled upon this thread.

I have a similar problem but after much testing I have narrowed it down to one plugin that is causing the error: Yoast’s WordPress SEO.

Where should the rewrite rules for his plugin go? Which configuration file?

It is the one thing stopping my site from working great and it’s driving me nuts! :frowning:

Surely there is a workaround/solution for all to work correctly together?

I have read your recommended rules at but alas no luck.

One little matter stopping it from working beautifully - be great if there’s any solution.

Sorry for bumping the OP’s thread, but issues were too similar to create another thread!


#10

Hi g.dooce,
can you post us the output for following

lsb_release -d  
ee version  
ee site show yourdomain  
cat /etc/nginx/common/wpcommon.conf  

so that we can debug furthur.


#11

I eventually managed to find the solution myself.

Weirdly I just changed the order of my domain name in the server_name variable under my Nginx config file for my particular domain.

I put the www. version first, then the non www version second.

Seems to work find now — but is it a bit bizarre that WordPress SEO would have anything to do with it?!


#12

@g.dooce
pleasure to know that your problem solved. Thanks for sharing your solution with us.


#13