RewriteRule : Altering the current protocol

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RewriteRule : Altering the current protocol

Philippe Busque
Hello,
I have a configuration question regarding RewriteRule.

We have a SSL terminator in front of our Apache, which redirect traffic to different port based virtual host depending on which protocol the connection came from.
As a result, Apache is only responding to HTTP requests.

We have RewriteRule that perform relative 301 and 302 redirections.

Exemple: RewriteRule ^/deprecatedPage.html$ / [R=301,L,E=nocache:1]

According to the documentations:
"If a fully-qualified URL is specified (that is, including http://servername/) then a redirect will be issued to that location. Otherwise, the *current protocol*, servername, and port number will be used to generate the URL sent with the redirect. "

Because of the current protocol clause, all URL that are sent to a https address are redirected back to http. We have a catch all http to https redirection too, but that cause two redirections in a row we would like to avoid.

Other than inputing the absolute URL to the destination, is it possible to change the 'current protocol' so that mod_rewrite  put https rather than http?

I tried SetEnv SERVER_PROTOCOL=https  without success.

Thanks

--

*Philippe Busque*
1111, rue St-Charles Ouest,
Tour Est, bureau 255
Longueuil (Québec) Canada J4K 5G4
Tél. : 450-449-0102 ext. 3017
Télec. : 450-449-8725

Ce message et les fichiers d’accompagnement transmis avec celui-ci s’adressent expressément au(x) destinataire(s) et peuvent contenir des renseignements confidentiels et privilégiés. Si vous recevez ce message par erreur, veuillez en aviser immédiatement l’expéditeur par courrier électronique. Veuillez également ne pas en prendre connaissance et en supprimer toutes les copies immédiatement. Technologies Interactives Mediagrif Inc. et ses filiales n’acceptent aucune responsabilité à l’égard des opinions exprimées dans le message ou des conséquences de tout virus informatique qui pourrait être transmis avec ce message. Ce message fait également l’objet d’un copyright. Il est interdit d’en reproduire, adapter ou transmettre quelque partie que ce soit sans le consentement écrit du détenteur du copyright.

This email and any files transmitted with it are solely intended for the use of the addressee(s) and may contain information that is confidential and privileged. If you receive this email in error, please advise us by return email immediately. Please also disregard the contents of the email, delete it and destroy any copies immediately. Mediagrif Interactive Technologies Inc. and its subsidiaries do not accept liability for the views expressed in the email or for the consequences of any computer viruses that may be transmitted with this email. This email is also subject to copyright. No part of it should be reproduced, adapted or transmitted without the written consent of the copyright owner.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RewriteRule : Altering the current protocol

Konstantin Kolinko
2017-08-07 18:42 GMT+03:00 Philippe Busque <[hidden email]>:

> Hello,
> I have a configuration question regarding RewriteRule.
>
> We have a SSL terminator in front of our Apache, which redirect traffic to
> different port based virtual host depending on which protocol the connection
> came from.
> As a result, Apache is only responding to HTTP requests.
>
> We have RewriteRule that perform relative 301 and 302 redirections.
>
> Exemple: RewriteRule ^/deprecatedPage.html$ / [R=301,L,E=nocache:1]
>
> According to the documentations:
> "If a fully-qualified URL is specified (that is, including
> http://servername/) then a redirect will be issued to that location.
> Otherwise, the *current protocol*, servername, and port number will be used
> to generate the URL sent with the redirect. "
>
> Because of the current protocol clause, all URL that are sent to a https
> address are redirected back to http. We have a catch all http to https
> redirection too, but that cause two redirections in a row we would like to
> avoid.
>
> Other than inputing the absolute URL to the destination, is it possible to
> change the 'current protocol' so that mod_rewrite  put https rather than
> http?
>
> I tried SetEnv SERVER_PROTOCOL=https  without success.

It sounds similar to the question that I answered in January:

http://markmail.org/message/a43q65rmszqf5t4j
[users@httpd] Configuring redirects httpd behind a TLS-terminating proxy
Jan 23, 2017 2:07:13 pm

Solved by configuring ServerName to include https protocol.
http://httpd.apache.org/docs/2.4/mod/core.html#servername

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Loading...