Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 374
codewithfeeling Avatar asked Jan 26 '13 00:01

codewithfeeling


People also ask

How do I fix the login redirect loop in WordPress?

Clear Your Browser Cookies and Cache The quickest way to solve the WordPress login redirect issue is by clearing your browser cookies and cache. WordPress uses cookies to store authentication data. Sometimes your browser might retain old files, resulting in a redirect loop when you try to log in to your site.

How do I redirect a WordPress user to login?

Set Up Login Redirect for Specific WordPress Users To do this, click the 'Add New' button in the 'Redirection Rules' section. This brings you to a new page to set your redirection settings. First, select the 'Username' condition from the 'Rule Condition' drop down and choose the username from the drop down list.

How do I redirect a WordPress page using PHP?

To redirect your entire site to a single new location, open functions. php in a text editor and add the native WordPress wp_redirect function by appending the following lines to the end of the file: wp_redirect( “http://www.my-blog.com/a-new-destination”, 301 );


1 Answers

For whatever reason /wp-admin/ path causes a redirect loop, but /wp-admin/index.php does not. As such, we can use .htaccess to redirect the /wp-admin/ path to /wp-admin/index.php by adding the following line to your .htaccess file after "RewriteBase /" line like this:

RewriteBase /
RewriteRule  /wp-admin/ /wp-admin/index\.php [L,P]

It worked for me like that. You final .htaccess would 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
like image 90
GandalfTheWhite Avatar answered Sep 21 '22 00:09

GandalfTheWhite