Htaccess working fine on one server and causing redirect loop on other

Asked
Active3 hr before
Viewed126 times

8 Answers

serverworking
90%

Meta Stack Overflow , Stack Overflow Public questions & answers , Stack Overflow help chat , Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers

The loop is being caused by the following two lines:

RewriteCond % {
   HTTP_HOST
} ^ 108\ .175\ .155\ .54
RewriteRule ^ (.*) $ http: //108.175.155.54/$1 [R=permanent,L]
88%

Just in case, here is the htaccess file:,It won't check .htaccess files though, but it can still help to find easily overlooked .htaccess files:,Comparing the two machines non-.htaccess configuration:,Asking for help, clarification, or responding to other answers.

It won't check .htaccess files though, but it can still help to find easily overlooked .htaccess files:

find $(httpd - dump - config | grep - i DocumentRoot | awk '{print $2}') - type f - name '.htaccess' - print

Comparing the two machines non-.htaccess configuration:

diff < (httpd - dump - config)\ <
   (ssh webserverB.dom httpd - dump - config)
load more v
72%

We come across a lot of different errors here at Kinsta, and ERR_TOO_MANY_REDIRECTS (also known as a redirect loop) is one we see on a regular basis. Typically this occurs after a recent change on your website, a misconfiguration of redirects on your server, or wrong settings with third-party services. But don’t worry, this error is fairly easy to fix.,In Google Chrome this error will show as ERR_TOO_MANY_REDIRECTS (as seen below) or This webpage has a redirect loop problem.,Redirect loops can sometimes be tricky to track down. But hopefully, some of the troubleshooting steps above help you to resolve your ERR_TOO_MANY_REDIRECTS error. If we missed anything, feel free to let us know below in the comments. ,The reason for ERR_TOO_MANY_REDIRECTS is pretty much what it sounds like, something is causing too many redirects, sending your website into an infinite redirection loop.

If your web server is running Nginx, you can easily redirect all of your HTTP traffic to HTTPS by adding the following code to your Nginx config file. This is the recommended method for redirecting WordPress running on Nginx.

server {
   listen 80;
   server_name domain.com www.domain.com;
   return 301 https: //domain.com$request_uri; }
load more v
65%

The ‘Error too many redirects’ is caused by a misconfigured redirection issue in WordPress. ,Are you trying to fix the ‘Error Too Many Redirects’ issue on your WordPress website? ,Hey, this was my problem! Thanks for your comment here.,If you are experiencing “Too many redirects” problem with WordPress

Next, you need to add the following code at the bottom:

update_option('siteurl', 'https://example.com');
update_option('home', 'https://example.com');
75%

The .htaccess code below first checks if the request came into the server using HTTP or HTTPS. If the request did not use HTTPS, then the configuration will tell the browser to redirect over to the HTTPS version of the same website and URL that was requested before.,VPS HostingLightning-fast cloud VPS hosting with root access.,This last redirect checks if the website name was not requested with www at the start of the domain name. If the www is not included, it rewrites the request and tells the browser to redirect over to the www version of the domain.,This redirect only checks if the website name was requested with www at the start of the domain name. If the www is included, it rewrites the request and tells the browser to redirect over to the non-www version of the domain name.

curl - svILk https: //www.example.com
   ....*Maximum(50) redirects followed
load more v
40%

Write for DigitalOcean , DigitalOcean on GitHub , 0 LewisWright June 22, 2016 Reply Report A quick note: I have spoken with the dns providers and they have assured me that everything on their end is correct and there should be no loops there. ,A quick note: I have spoken with the dns providers and they have assured me that everything on their end is correct and there should be no loops there.

I have a droplet that seems to be stuck in a redirect loop for no apparent reason. My client wanted all traffic to point to a www address rather than the non www address which was fine until I tried to do the redirect using my apache config.

Redirect permanent / http: //www.mysite.com/
load more v
22%

This redirect loop error occurs due to a few reasons:,This article will show several ways to solve the ERR_TOO_MANY_REDIRECTS error. You will also learn what causes it and how it looks on different web browsers.,Here are the steps you should follow to delete the browser’s cache and cookies:,The redirect loop error usually occurs when webmasters accidentally make their WordPress site point at the wrong domain when migrating hosts or changing domain names. 

If it works, check the .htaccess file’s configuration by right-clicking on it and selecting Edit. It should look like the default .htaccess configuration. Otherwise, delete the content from the file and paste these default rules instead:

# 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
60%

Now your browser will auto-clear cookies when you visit your site. If you’re still getting a redirect loop error, you can move on to the next step.,Because the WordPress permalink structure and many of its plugins have redirect functionality, it’s common to see a redirect loop error.,In some cases, an error on the browser’s side — not your site’s server — may be causing the redirect loop. When you visit a site, your browser stores cookies to help it load faster the next time you visit that site. If your browser has stored cookies from two different sites that share the same IP address, it can cause a redirect loop error. For a one-time fix, you can manually clear cookies in the History section of your browser's settings.,One of the most common misconfigurations that causes a redirect loop is that your WordPress Address and Site Address differ from the permalinks you configured with your hosting provider. The difference could be as small as one address having the www prefix and the other not.

 define('ADMIN_COOKIE_PATH', '/');
 define('COOKIE_DOMAIN', '');
 define('COOKIEPATH', '');
 define('SITECOOKIEPATH', '');
load more v

Other "server-working" queries related to "Htaccess working fine on one server and causing redirect loop on other"