RedirectMatch matching hostname
Clash 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 !
linux apache-httpd
add a comment |Â
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 !
linux apache-httpd
add a comment |Â
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 !
linux apache-httpd
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
linux apache-httpd
asked Oct 2 '17 at 14:07
DaWe4444
639
639
add a comment |Â
add a comment |Â
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
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
add a comment |Â
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
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
add a comment |Â
up vote
2
down vote
the following lines should be simply enough
ServerName anynameyoucanimagine.exampledomain.com
RedirectMatch /(.*) https://anynameyoucanimagine.exampledomain.com/$1
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
add a comment |Â
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
the following lines should be simply enough
ServerName anynameyoucanimagine.exampledomain.com
RedirectMatch /(.*) https://anynameyoucanimagine.exampledomain.com/$1
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
add a comment |Â
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
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password