On Wed, 24 Jan 2007, Jonathan Vanasco wrote:
On Jan 24, 2007, at 1:21 AM, Igor Sysoev wrote:
On Wed, 24 Jan 2007, Jason B wrote:
RewriteRule ^index.html$ index%{HTTP_COOKIE['cookieName']}.html
location = /index.html {
set $name "";
if ($http_cookie ~ "cookieName=([^;]+)(?:;|$)") {
set $name $1;
}
index index$name.html;
}
would this also work?
if ($http_cookie ~ "cookieName=([^;]+)(?:;|$)") {
rewrite index$1 ;
}
No, the $1 inside the "rewrite" directive is possible rewrite's capture.
You may use
if ($http_cookie ~ "cookieName=([^;]+)(?:;|$)") {
set $name $1;
rewrite ^/index.html$ index$name.html;
}
I was wrong with
location = /index.html {
set $name "";
if ($http_cookie ~ "cookieName=([^;]+)(?:;|$)") {
set $name $1;
}
index index$name.html;
}
because the "index" directive is useless in the "location = /index.html".
It has meaning inside "location = /", "location ~ /$", or "location /".