Hello,
I am in the process of implementing persistent sessions using
Apache::Session with the session_id stored in the URL and it mostly
works. In the HTML::Mason autohandler there is the following filter:
<%filter>
$r->pnotes("cookie") # mangle URL only if cookie is missing
|| s#\bhref\s*=\s*"(/(?!S=)[^"\s]*)"#href="/S=$session{_session_id}$1"#gi;
</%filter>
... which adds the session_id to all href links, only if the browser
doesn't return any cookie.
Now in httpd.conf there is a mod_rewrite rule inspired by a recent
thread on the modperl list:
RewriteRule ^/S=([^/]+)(/.*) $2 [E=AF_SID:$1]
This removes the session_id from the URL and adds it to the AF_SID
environment variable. This works well for all absolute URLs (starting
with a /) which is puzzling because I remember reading in this thread
that this technique mandated _relative_ URLs.
The rewrite rule fails only in one case, the root URL:
http://my.site.com/S=1d2e580af1e31cf2/Sell/index.html
... is correctly converted to
http://my.site.com/Sell/index.html
... *but*
http://my.site.com/S=1d2e580af1e31cf2/
... fails with a 404 NOT FOUND error
>From the rewrite log:
127.0.0.1 - - [23/Jul/2000:15:57:31 +0200] [apartia.int/sid#815769c][rid#8149464
/initial] (2) init rewrite engine with requested uri /S=3b2c1685dcc26394/
127.0.0.1 - - [23/Jul/2000:15:57:31 +0200] [apartia.int/sid#815769c][rid#8149464
/initial] (3) applying pattern '^/S=([^/]+)(/.*)' to uri '/S=3b2c1685dcc26394/'
127.0.0.1 - - [23/Jul/2000:15:57:31 +0200] [apartia.int/sid#815769c][rid#8149464
/initial] (2) rewrite /S=3b2c1685dcc26394/ -> /
127.0.0.1 - - [23/Jul/2000:15:57:31 +0200] [apartia.int/sid#815769c][rid#8149464
/initial] (2) local path result: /
127.0.0.1 - - [23/Jul/2000:15:57:31 +0200] [apartia.int/sid#815769c][rid#8149464
/initial] (1) go-ahead with / [OK]
[Sun Jul 23 15:57:31 2000] [error] [client 127.0.0.1] File does not exist: /
... so after tinkering with various mod_rewrite options for a while I
changed the RewriteRule to:
RewriteRule ^/S=([^/]+)(/.*) %{DOCUMENT_ROOT}$2 [E=AF_SID:$1]
... and now everything works fine.
But I'm still not happy because I don't understand _why_ it works.
Please let me know if you have a rational explanation.
TIA
--
Louis-David Mitterrand - [EMAIL PROTECTED] - http://www.apartia.fr
# rm *;o
o : command not found