can we write rewrite rules in apache based on the value available in cookie. below is the sample cookie value (from firebug). In this i need to control my rewrite rule based on the value jforumUserId
JSESSIONID=96A0AFA5E2EE4500C8483679DA530041;
__utma=111872281.1699469794.1302588971.1305090522.1305099051.66;
__utmz=111872281.1302588971.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);
jforumUserId=1; __utmc=111872281
i need to force page load to https if jforumUserId value is other than -1. Is this possible.
$1 represents the match from the first set of parentheses in the RewriteRule regex, not in the RewriteCond regex.
A rewrite engine is a component of web server software that allows you to rewrite or redirect uniform resource locators (URLs). The most popular rewrite engine is the Apache HTTP server's mod_rewrite. There are other web servers, such as nginx or lighttpd, that provide similar functions.
The mod_rewrite module uses a rule-based rewriting engine, based on a PCRE regular-expression parser, to rewrite requested URLs on the fly. By default, mod_rewrite maps a URL to a filesystem path. However, it can also be used to redirect one URL to another URL, or to invoke an internal proxy fetch.
Try this:
RewriteCond %{HTTP:Cookie} (^|;\ *)jforumUserId=([^;\ ]+)
RewriteCond %2 !=-1
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With