Wordpress causing “This webpage has a redirect loo

2019-04-08 17:14发布

I have a Wordpress site that works perfectly well in development (at mysite.dev), however when I deploy it to my remote server (mysite.com) it throws the 'This webpage has a redirect loop' error.

I can see in the loading bar that the browser is trying www.mysite.com then mysite.com then www.mysite.com again and again, however I'm not sure if this is relavant or not.

If my Wordpress database configuration is incorrect, I get the Error establishing a database connection message, however when everything is set correctly it breaks in this re-direct loop thing.

I have changed the field in the database (siteurl) to reflect the remote settings (http://mysite.com/wordpress).

Note: My wordpress files are stored in a folder called wordpress in my root directory except for wp-config.php, index.php and .htaccess.

Any ideas?

.htaccess contents:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

index.php:

<?php
/**
 * @package WordPress
 */
define('WP_USE_THEMES', true);

require('./wordpress/wp-blog-header.php');
?>

9条回答
女痞
2楼-- · 2019-04-08 17:52

First of all I'm just a beginner so... Meanwhile I think that I may have an alternative/shortcut to this issue.

Instead of deleting every plugin and then reinstalling all of them one by one I suggest to start by deleting the lasted plugins because "resent problem = recent modification/plugins"...

That is just my suggestion.

Marco Davide

查看更多
唯我独甜
3楼-- · 2019-04-08 17:59

1.- As "My wordpress files are stored in a folder called wordpress" you must edit RewriteBase and RewriteRule like this:

RewriteBase /wordpress/
RewriteRule . /wordpress/index.php [L]

UPDATE

2.- Try cleaning all cookies. This simple action (through Firebug) has solved this problem to me sometimes.

UPDATE 3

3.- Try this /index.php in your root directory:

// index.php file in root directory
chdir('wordpress'); // change dir to WP
include 'index.php'; // execute WP with their normal `index.php`

and leave /wordpress directory as usual (with their normal index.php and .htaccess inside).

I mean don't change any bit of the normal index.php of WP that it is something like this:

<?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require('./wp-blog-header.php');
查看更多
做个烂人
4楼-- · 2019-04-08 18:04

Though I found this post and solution really helpful because this problem was driving me crazy and took me so much time to realize. In my case it happened because I moved the files inside the same server but using another domain and after finishing all configurations and replacements I was not able to view pages and got this error. In my hosting settings there was a Preferred domain filed which was set to domain.ltd (I tried to change it but finally left it so) and than in Settings->General wordpress dashboard I had WordPress Address (URL) "mysite.com" and Site Address (URL) set to "www.mysite.com" after setting last value without www..bum everything is okay now. Hope this helps anyone else

查看更多
冷血范
5楼-- · 2019-04-08 18:06

My hosted server settings were forcing mysite.com to www.mysite.com and this was causing the problem. I turned this setting off and everything works now, i'd still like to know how to make it work with this setting turned on, though!

查看更多
趁早两清
6楼-- · 2019-04-08 18:06

This error can happen in one of two places, on the user side, or on the admin side.

When it happens on the admin side (wp-admin), you will find that you are unable to login.

Step 1: Connect to your blog using ftp and navigate to your wp-content/plugins/ directory and download all of your plugins to a folder on your desktop. Step 3: Still in your FTP program, delete all plugin folders and php files in the plugins directory. You do not want anything at all left in this directory. Step 4: Try logging into your blog. It should let you log in with no problems. Visit the plugins section of your blog. This should load with a lot of errors telling you that each plugin has been deactivated due to an error. This is ok. Step 5: Using your ftp program you should upload all your plugins. Once uploaded you should activate each plugin one by one within wordpress and then visit the wp-admin/ login address to make sure that it will pass you through to your blog once logged in. Step 6: When you activate a plugin and start getting this error again, you will know which one is to blame. Simply delete that plugin via ftp and start looking for an alternative plugin to use.

If these steps do not fix your problem, you should backup all your wordpress files and then delete them. You should them upload clean wordpress files for the latest version and try logging in with no themes or plugins uploaded. You can upload these later once you can login.

If you continue getting error, clear your browser cache, test logging in with other browsers.

If all else fails, contact your webhost or open a thread on the wordpress support forum

查看更多
兄弟一词,经得起流年.
7楼-- · 2019-04-08 18:11

Note that the infinite redirection problem can also occur when using CloudFlare Flexible SSL. To fix it you need to install the following plugin:

https://wordpress.org/plugins/cloudflare-flexible-ssl

查看更多
登录 后发表回答