trying to do http to https based on header value of the request but failing some how.can some one help me here.
request is if a header value is xyz and it is equal to Y then serve http pages,for all other requests serve https pages. immediately i have another condition inside proxy module which has to be executed but it is failing to execute.
also unable to see Log traces for rewrite in error logs.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP:xyz} !=Y [NC] --> if header contains xyz and its value is not equal to Y
Rewrite ^/?(.*) https://%{SERVER_NME}/$1 [R,L] --> server https page.
LogLevel alert mod_rewrite.c:trace3 --> Log the rewrite activity.
<IfModule mod_proxy_http.c> --> after above activity is completed continue this activity.
RewriteCond ...
RewriteCond ...
RewriteRule ...
<Ifmodule>
<IfModule>
Apache Version : 2.4
Best Answer
I only fixed your
RewriteRule
and added an additional protocol check. If you have different vhosts for HTTP and HTTPS, you can remove the protocol check. Just wanted to make sure there is no redirection loop if you're already on the HTTPS site.To check if the header works I used
wget
: