RedirectMatch matching hostname

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I'm using apache 2.4



I would like to redirect any HTTP traffic to HTTPS matching any canonical domain of the apex domain. I know it's possible to do it via RewriteRules but I would like to use RedirectMatch instead, where it takes the domain name from the HTTP header.



ServerName exampledomain.com
ServerAlias *.exampledomain.com
<If "%SERVER_PROTOCOL != 'HTTPS'">
RedirectMatch (.*) "https://%HTTP_HOST$1"
</If>


So when you ask for http://anynameyoucanimagine.exampledomain.com it redirects you to https://anynameyoucanimagine.exampledomain.com.



Any ideas ?



Thanks a lot !










share|improve this question

























    up vote
    1
    down vote

    favorite












    I'm using apache 2.4



    I would like to redirect any HTTP traffic to HTTPS matching any canonical domain of the apex domain. I know it's possible to do it via RewriteRules but I would like to use RedirectMatch instead, where it takes the domain name from the HTTP header.



    ServerName exampledomain.com
    ServerAlias *.exampledomain.com
    <If "%SERVER_PROTOCOL != 'HTTPS'">
    RedirectMatch (.*) "https://%HTTP_HOST$1"
    </If>


    So when you ask for http://anynameyoucanimagine.exampledomain.com it redirects you to https://anynameyoucanimagine.exampledomain.com.



    Any ideas ?



    Thanks a lot !










    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I'm using apache 2.4



      I would like to redirect any HTTP traffic to HTTPS matching any canonical domain of the apex domain. I know it's possible to do it via RewriteRules but I would like to use RedirectMatch instead, where it takes the domain name from the HTTP header.



      ServerName exampledomain.com
      ServerAlias *.exampledomain.com
      <If "%SERVER_PROTOCOL != 'HTTPS'">
      RedirectMatch (.*) "https://%HTTP_HOST$1"
      </If>


      So when you ask for http://anynameyoucanimagine.exampledomain.com it redirects you to https://anynameyoucanimagine.exampledomain.com.



      Any ideas ?



      Thanks a lot !










      share|improve this question













      I'm using apache 2.4



      I would like to redirect any HTTP traffic to HTTPS matching any canonical domain of the apex domain. I know it's possible to do it via RewriteRules but I would like to use RedirectMatch instead, where it takes the domain name from the HTTP header.



      ServerName exampledomain.com
      ServerAlias *.exampledomain.com
      <If "%SERVER_PROTOCOL != 'HTTPS'">
      RedirectMatch (.*) "https://%HTTP_HOST$1"
      </If>


      So when you ask for http://anynameyoucanimagine.exampledomain.com it redirects you to https://anynameyoucanimagine.exampledomain.com.



      Any ideas ?



      Thanks a lot !







      linux apache-httpd






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Oct 2 '17 at 14:07









      DaWe4444

      639




      639




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          2
          down vote













          the following lines should be simply enough



          ServerName anynameyoucanimagine.exampledomain.com
          RedirectMatch /(.*) https://anynameyoucanimagine.exampledomain.com/$1





          share|improve this answer




















          • Yeah, but I can't have it hard written, there are hundreds of subdomain names which I need to match.
            – DaWe4444
            Oct 2 '17 at 14:33










          • if %HTTP_HOST variable does not work, you may need to use mod_rewrite as explained here stackoverflow.com/questions/23059463/…
            – lese
            Oct 2 '17 at 14:37











          • Yes, that's why I'm asking if anyone has any idea solving it via RedirectMatch. Also mod_rewrite is slower then redirect.
            – DaWe4444
            Oct 2 '17 at 14:48











          • Since I think there is not a possible way to do it one line using RedirectMatch, and you do not want to use mod_rewrite because its less performant, I think you have to repeat the above lines or similar, for all the hundreds VHosts. Or better, I think you will have to give up and use mod_rewrite at the end
            – lese
            Oct 2 '17 at 15:40











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          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',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f395657%2fredirectmatch-matching-hostname%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          2
          down vote













          the following lines should be simply enough



          ServerName anynameyoucanimagine.exampledomain.com
          RedirectMatch /(.*) https://anynameyoucanimagine.exampledomain.com/$1





          share|improve this answer




















          • Yeah, but I can't have it hard written, there are hundreds of subdomain names which I need to match.
            – DaWe4444
            Oct 2 '17 at 14:33










          • if %HTTP_HOST variable does not work, you may need to use mod_rewrite as explained here stackoverflow.com/questions/23059463/…
            – lese
            Oct 2 '17 at 14:37











          • Yes, that's why I'm asking if anyone has any idea solving it via RedirectMatch. Also mod_rewrite is slower then redirect.
            – DaWe4444
            Oct 2 '17 at 14:48











          • Since I think there is not a possible way to do it one line using RedirectMatch, and you do not want to use mod_rewrite because its less performant, I think you have to repeat the above lines or similar, for all the hundreds VHosts. Or better, I think you will have to give up and use mod_rewrite at the end
            – lese
            Oct 2 '17 at 15:40















          up vote
          2
          down vote













          the following lines should be simply enough



          ServerName anynameyoucanimagine.exampledomain.com
          RedirectMatch /(.*) https://anynameyoucanimagine.exampledomain.com/$1





          share|improve this answer




















          • Yeah, but I can't have it hard written, there are hundreds of subdomain names which I need to match.
            – DaWe4444
            Oct 2 '17 at 14:33










          • if %HTTP_HOST variable does not work, you may need to use mod_rewrite as explained here stackoverflow.com/questions/23059463/…
            – lese
            Oct 2 '17 at 14:37











          • Yes, that's why I'm asking if anyone has any idea solving it via RedirectMatch. Also mod_rewrite is slower then redirect.
            – DaWe4444
            Oct 2 '17 at 14:48











          • Since I think there is not a possible way to do it one line using RedirectMatch, and you do not want to use mod_rewrite because its less performant, I think you have to repeat the above lines or similar, for all the hundreds VHosts. Or better, I think you will have to give up and use mod_rewrite at the end
            – lese
            Oct 2 '17 at 15:40













          up vote
          2
          down vote










          up vote
          2
          down vote









          the following lines should be simply enough



          ServerName anynameyoucanimagine.exampledomain.com
          RedirectMatch /(.*) https://anynameyoucanimagine.exampledomain.com/$1





          share|improve this answer












          the following lines should be simply enough



          ServerName anynameyoucanimagine.exampledomain.com
          RedirectMatch /(.*) https://anynameyoucanimagine.exampledomain.com/$1






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Oct 2 '17 at 14:31









          lese

          2,11021227




          2,11021227











          • Yeah, but I can't have it hard written, there are hundreds of subdomain names which I need to match.
            – DaWe4444
            Oct 2 '17 at 14:33










          • if %HTTP_HOST variable does not work, you may need to use mod_rewrite as explained here stackoverflow.com/questions/23059463/…
            – lese
            Oct 2 '17 at 14:37











          • Yes, that's why I'm asking if anyone has any idea solving it via RedirectMatch. Also mod_rewrite is slower then redirect.
            – DaWe4444
            Oct 2 '17 at 14:48











          • Since I think there is not a possible way to do it one line using RedirectMatch, and you do not want to use mod_rewrite because its less performant, I think you have to repeat the above lines or similar, for all the hundreds VHosts. Or better, I think you will have to give up and use mod_rewrite at the end
            – lese
            Oct 2 '17 at 15:40

















          • Yeah, but I can't have it hard written, there are hundreds of subdomain names which I need to match.
            – DaWe4444
            Oct 2 '17 at 14:33










          • if %HTTP_HOST variable does not work, you may need to use mod_rewrite as explained here stackoverflow.com/questions/23059463/…
            – lese
            Oct 2 '17 at 14:37











          • Yes, that's why I'm asking if anyone has any idea solving it via RedirectMatch. Also mod_rewrite is slower then redirect.
            – DaWe4444
            Oct 2 '17 at 14:48











          • Since I think there is not a possible way to do it one line using RedirectMatch, and you do not want to use mod_rewrite because its less performant, I think you have to repeat the above lines or similar, for all the hundreds VHosts. Or better, I think you will have to give up and use mod_rewrite at the end
            – lese
            Oct 2 '17 at 15:40
















          Yeah, but I can't have it hard written, there are hundreds of subdomain names which I need to match.
          – DaWe4444
          Oct 2 '17 at 14:33




          Yeah, but I can't have it hard written, there are hundreds of subdomain names which I need to match.
          – DaWe4444
          Oct 2 '17 at 14:33












          if %HTTP_HOST variable does not work, you may need to use mod_rewrite as explained here stackoverflow.com/questions/23059463/…
          – lese
          Oct 2 '17 at 14:37





          if %HTTP_HOST variable does not work, you may need to use mod_rewrite as explained here stackoverflow.com/questions/23059463/…
          – lese
          Oct 2 '17 at 14:37













          Yes, that's why I'm asking if anyone has any idea solving it via RedirectMatch. Also mod_rewrite is slower then redirect.
          – DaWe4444
          Oct 2 '17 at 14:48





          Yes, that's why I'm asking if anyone has any idea solving it via RedirectMatch. Also mod_rewrite is slower then redirect.
          – DaWe4444
          Oct 2 '17 at 14:48













          Since I think there is not a possible way to do it one line using RedirectMatch, and you do not want to use mod_rewrite because its less performant, I think you have to repeat the above lines or similar, for all the hundreds VHosts. Or better, I think you will have to give up and use mod_rewrite at the end
          – lese
          Oct 2 '17 at 15:40





          Since I think there is not a possible way to do it one line using RedirectMatch, and you do not want to use mod_rewrite because its less performant, I think you have to repeat the above lines or similar, for all the hundreds VHosts. Or better, I think you will have to give up and use mod_rewrite at the end
          – lese
          Oct 2 '17 at 15:40


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f395657%2fredirectmatch-matching-hostname%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?