htaccess redirect http to https causes redirect loopIn Nginx, how can I rewrite all http requests to https...

What is a term for a function that when called repeatedly, has the same effect as calling once?

Second-rate spelling

RS232 to Raspberry Pi Zero W

Real life puzzle: Unknown alphabet or shorthand

Six real numbers so that product of any five is the sixth one

Are there any other Chaos-worshipping races?

How do you say "powers of ten"?

Inverse of the covariance matrix of a multivariate normal distribution

How to kill a localhost:8080

What am I? I am in theaters and computer programs

Borrowing Characters

Get length of the longest sequence of numbers with the same sign

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

Is it possible to convert a suspension fork to rigid by drilling it?

What is this waxed root vegetable?

Dystopian novel where telepathic humans live under a dome

Make me a metasequence

I can't die. Who am I?

If nine coins are tossed, what is the probability that the number of heads is even?

Do higher etale homotopy groups of spectrum of a field always vanish?

Why are special aircraft used for the carriers in the united states navy?

At what level can a party fight a mimic?

Didactic impediments of using simplified versions

How do I deal with being jealous of my own players?



htaccess redirect http to https causes redirect loop


In Nginx, how can I rewrite all http requests to https while maintaining sub-domain?Endless Redirect Loop with AWS ELB and wordpress site using wordpress https plugin.htaccess rewrite http to https results in loopRedirect HTTPS to HTTP.htaccess redirect just the root of my site to httpredirect for root domain only not subdomainsRedirect to absolute URL in .htaccess returns wrong host name on OpenShifthttp to https including www 301 redirectApache returning wrong Location headerredirect http to https using .htaccess failing













0















I have edited my .htaccess file to redirect any http request to https://mydomain.se however, this has cause the website to fall in redirect loop. I have looked at the other solutions and compared them however I detected nothing wrong.



RewriteEngine On 
RewriteCond %{HTTP_HOST} ^(www.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www.)?(.+)
RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]


If it does help, domain is bitech.se










share|improve this question














bumped to the homepage by Community 20 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    0















    I have edited my .htaccess file to redirect any http request to https://mydomain.se however, this has cause the website to fall in redirect loop. I have looked at the other solutions and compared them however I detected nothing wrong.



    RewriteEngine On 
    RewriteCond %{HTTP_HOST} ^(www.)(.+) [OR]
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^(www.)?(.+)
    RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]


    If it does help, domain is bitech.se










    share|improve this question














    bumped to the homepage by Community 20 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0








      I have edited my .htaccess file to redirect any http request to https://mydomain.se however, this has cause the website to fall in redirect loop. I have looked at the other solutions and compared them however I detected nothing wrong.



      RewriteEngine On 
      RewriteCond %{HTTP_HOST} ^(www.)(.+) [OR]
      RewriteCond %{HTTPS} off
      RewriteCond %{HTTP_HOST} ^(www.)?(.+)
      RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]


      If it does help, domain is bitech.se










      share|improve this question














      I have edited my .htaccess file to redirect any http request to https://mydomain.se however, this has cause the website to fall in redirect loop. I have looked at the other solutions and compared them however I detected nothing wrong.



      RewriteEngine On 
      RewriteCond %{HTTP_HOST} ^(www.)(.+) [OR]
      RewriteCond %{HTTPS} off
      RewriteCond %{HTTP_HOST} ^(www.)?(.+)
      RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]


      If it does help, domain is bitech.se







      .htaccess redirect https






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 9 '13 at 14:34









      ErfanErfan

      33




      33





      bumped to the homepage by Community 20 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 20 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Your RewriteCond seems to always match, as the HTTPS version redirects back to the HTTPS over and over.



          Try this instead:



          RewriteCond %{HTTPS} !=on





          share|improve this answer
























          • Now it says Moved Permanently. The document has moved here. here refers to "https:///" why???

            – Erfan
            Mar 9 '13 at 14:54











          • You're trying to redirect to https:/// which doesn't actually contain a hostname. Perhaps you should actually use the hostname, instead of %2.

            – Michael Hampton
            Mar 9 '13 at 14:58













          • Thanks, I did that. However, still no luck.

            – Erfan
            Mar 9 '13 at 15:06











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "2"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f486257%2fhtaccess-redirect-http-to-https-causes-redirect-loop%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Your RewriteCond seems to always match, as the HTTPS version redirects back to the HTTPS over and over.



          Try this instead:



          RewriteCond %{HTTPS} !=on





          share|improve this answer
























          • Now it says Moved Permanently. The document has moved here. here refers to "https:///" why???

            – Erfan
            Mar 9 '13 at 14:54











          • You're trying to redirect to https:/// which doesn't actually contain a hostname. Perhaps you should actually use the hostname, instead of %2.

            – Michael Hampton
            Mar 9 '13 at 14:58













          • Thanks, I did that. However, still no luck.

            – Erfan
            Mar 9 '13 at 15:06
















          0














          Your RewriteCond seems to always match, as the HTTPS version redirects back to the HTTPS over and over.



          Try this instead:



          RewriteCond %{HTTPS} !=on





          share|improve this answer
























          • Now it says Moved Permanently. The document has moved here. here refers to "https:///" why???

            – Erfan
            Mar 9 '13 at 14:54











          • You're trying to redirect to https:/// which doesn't actually contain a hostname. Perhaps you should actually use the hostname, instead of %2.

            – Michael Hampton
            Mar 9 '13 at 14:58













          • Thanks, I did that. However, still no luck.

            – Erfan
            Mar 9 '13 at 15:06














          0












          0








          0







          Your RewriteCond seems to always match, as the HTTPS version redirects back to the HTTPS over and over.



          Try this instead:



          RewriteCond %{HTTPS} !=on





          share|improve this answer













          Your RewriteCond seems to always match, as the HTTPS version redirects back to the HTTPS over and over.



          Try this instead:



          RewriteCond %{HTTPS} !=on






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 9 '13 at 14:42









          Michael HamptonMichael Hampton

          171k27312636




          171k27312636













          • Now it says Moved Permanently. The document has moved here. here refers to "https:///" why???

            – Erfan
            Mar 9 '13 at 14:54











          • You're trying to redirect to https:/// which doesn't actually contain a hostname. Perhaps you should actually use the hostname, instead of %2.

            – Michael Hampton
            Mar 9 '13 at 14:58













          • Thanks, I did that. However, still no luck.

            – Erfan
            Mar 9 '13 at 15:06



















          • Now it says Moved Permanently. The document has moved here. here refers to "https:///" why???

            – Erfan
            Mar 9 '13 at 14:54











          • You're trying to redirect to https:/// which doesn't actually contain a hostname. Perhaps you should actually use the hostname, instead of %2.

            – Michael Hampton
            Mar 9 '13 at 14:58













          • Thanks, I did that. However, still no luck.

            – Erfan
            Mar 9 '13 at 15:06

















          Now it says Moved Permanently. The document has moved here. here refers to "https:///" why???

          – Erfan
          Mar 9 '13 at 14:54





          Now it says Moved Permanently. The document has moved here. here refers to "https:///" why???

          – Erfan
          Mar 9 '13 at 14:54













          You're trying to redirect to https:/// which doesn't actually contain a hostname. Perhaps you should actually use the hostname, instead of %2.

          – Michael Hampton
          Mar 9 '13 at 14:58







          You're trying to redirect to https:/// which doesn't actually contain a hostname. Perhaps you should actually use the hostname, instead of %2.

          – Michael Hampton
          Mar 9 '13 at 14:58















          Thanks, I did that. However, still no luck.

          – Erfan
          Mar 9 '13 at 15:06





          Thanks, I did that. However, still no luck.

          – Erfan
          Mar 9 '13 at 15:06


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Server Fault!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f486257%2fhtaccess-redirect-http-to-https-causes-redirect-loop%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          As a Security Precaution, the user account has been locked The Next CEO of Stack OverflowMS...

          Список ссавців Італії Природоохоронні статуси | Список |...

          Українські прізвища Зміст Історичні відомості |...