9 messages in ru.sysoev.nginxRe: Rewrite url based on cookie
FromSent OnAttachments
Jason BJan 23, 2007 10:04 pm 
Igor SysoevJan 23, 2007 10:21 pm 
Jason BJan 23, 2007 10:42 pm 
Jonathan VanascoJan 24, 2007 12:08 am 
Igor SysoevJan 24, 2007 12:20 am 
Jonathan VanascoJan 24, 2007 12:51 am 
Ian EvansJan 26, 2007 2:11 am 
Igor SysoevJan 26, 2007 4:17 am 
Ian EvansJan 26, 2007 8:35 am 
Actions with this message:
Paste this link in email or IM:
Paste this link in email or IM:
Atom feed for this thread
Paste this URL into your reader:
Subject:Re: Rewrite url based on cookieActions...
From:Igor Sysoev (is-G@public.gmane.org)
Date:Jan 24, 2007 12:20:40 am
List:ru.sysoev.nginx

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 /".