When Pointing From http//www To https//www Appear Redirect Loop

Posted July 2, 2019 897 views
ApacheUbuntu 18.04

Hello everyone.

I have some strange issue related to the redirect loop appearing.

For example, my website is in the website general setting I have the same address: in digitalocean domain setting I add that: is posting to IP is posting to the same IP

also in this file 000-default.conf (folder site enabled) I have those lines:

RewriteEngine on
RewriteCond %{SERVERNAME} [OR]
RewriteCond %{SERVER
RewriteRule ^ https://%{SERVERNAME}%{REQUESTURI} [END,NE,R=permanent]

and in the .httaces file, I have nothing.

*But when I enter to the browser this one I have those redirect chains: * 301 redirect to 301 redirect to

Somebody could help how to avoid the second unnecessary chain element in order to get the redirect from directly here: and from also directly here

Many thanks

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers


I believe that this might be an issue with your web application itself. You need to make sure that your application URL is setup correctly.

For example if you are using Wordpress you need to make sure that you update your Site and Home URLs as

Or if you are using Laravel for example make sure to set the correct app URL in your .env file.

Let me know how it goes!

  • Bobby, hi.

    As I wrote before in WordPress general settings the website is poiting as

    I suppose that the problem is in this directives that lies in this file 000-default.conf (folder site enabled):

    RewriteEngine on
    RewriteCond %{SERVERNAME} [OR]
    RewriteCond %{SERVERNAME}
    RewriteRule ^ https://%{SERVERNAME}%{REQUESTURI} [END,NE,R=permanent]

    Also I think that the problem could be in DigitalOcean Domain settings, is it right that I established? or how to make the alias of ?:

    A Records: is posting to IP is posting to the same IP

    If someone could help solve the problem I will really appreciate this.

    Many thanks

    • Thanks for the clarification! I see the problem now!

      So in your site settings you have but in your Apache conf it’s redirecting to

      You should change this line from:

      RewriteRule ^ https://%{SERVERNAME}%{REQUESTURI} [END,NE,R=permanent]


      RewriteRule ^ https://www.%1%{SERVERNAME}%{REQUESTURI} [END,NE,R=permanent]

      Make sure to run a config test before restarting Apache!


Yesterday I saw that left small issue - from this url don`t work the redirect here:

I use your code:

RewriteEngine on
RewriteCond %{SERVERNAME} [OR]
RewriteCond %{SERVERNAME}
RewriteRule ^ https://www.%1%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]

instead my old one:

RewriteEngine on
RewriteCond %{SERVERNAME} [OR]
RewriteCond %{SERVERNAME}
RewriteRule ^ https://%{SERVERNAME}%{REQUESTURI} [END,NE,R=permanent]

So i checked all redirect scenario: - redirect here - redirect here - don`t redirect here - is ok

So as you see this url: don`t redirect here:

Also actually I don`t know related it to this code or not, but also I use the special redirection plugin called “Redirection” for WordPress - I set-upped 301 redirect from the / - main page to another website.

And interesting thing - when I delete this redirect via redirection plugin all seems that works well and all redirection scenaria works well, but when I use the redirection plugin only this one scenario: - don`t redirect here

don`t work.

Tell, please should we customize the code that you provided or the problem in this “Redirection” plugin and could you help with this issue?

Many thanks.