You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Wesley Peng <we...@magenta.de> on 2020/01/09 02:43:45 UTC

Question on a rewrite rule

Hello

After installation of Letsencrypt free SSL, it adds a rule into apache's 
config file:

RewriteCond %{SERVER_NAME} =sample.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]


I know it means when SERVER_NAME is sample.com, it rewrites the plain 
HTTP request to HTTPS request.

My question is, is this not a dead loop?

For HTTPS request, the SERVER_NAME is also matched, so it rewrites again 
and again...

My guess it's a dead rewrite loop, but it actually works fine.

I am not sure about this, please help.

Thanks.

Re: AW: Question on a rewrite rule

Posted by Wesley Peng <we...@magenta.de>.
Hi

on 2020/1/9 14:27, Andreas Mock wrote:
> You have to see in which virtualhost section this rule was put into.
> I'm pretty sure it's only in the http section.

You are so right. they are put in plain HTTP section.
So requets were coming with HTTP, they will be rewriten to HTTPS, which 
is in another section, which doesn't have that rewrite config.

Regards.

AW: Question on a rewrite rule

Posted by Andreas Mock <an...@web.de>.
You have to see in which virtualhost section this rule was put into.
I'm pretty sure it's only in the http section.

-----Ursprüngliche Nachricht-----
Von: Wesley Peng <we...@magenta.de> 
Gesendet: Donnerstag, 9. Januar 2020 03:44
An: modperl@perl.apache.org
Betreff: Question on a rewrite rule

Hello

After installation of Letsencrypt free SSL, it adds a rule into apache's config file:

RewriteCond %{SERVER_NAME} =sample.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]


I know it means when SERVER_NAME is sample.com, it rewrites the plain HTTP request to HTTPS request.

My question is, is this not a dead loop?

For HTTPS request, the SERVER_NAME is also matched, so it rewrites again and again...

My guess it's a dead rewrite loop, but it actually works fine.

I am not sure about this, please help.

Thanks.