Revision 13617
Added by Aaron Marcuse-Kubitza over 10 years ago
trunk/web/.htaccess | ||
---|---|---|
13 | 13 |
|
14 | 14 |
SetEnvIf Request_URI ^ innermost_dir=/ |
15 | 15 |
|
16 |
# handle username-based prefix subpaths of the form "subpath@url?" |
|
17 |
# supports multiple @ and nested . : a@b.c@url? -> url?b.c.a
|
|
16 |
# handle username-based prefix subpaths of the form "subpath@url?" or "__?__&"
|
|
17 |
# supports multiple @ , nested . , & query str: a@b.c@url?k=v& -> url?b.c.a&k=v
|
|
18 | 18 |
# better than subpath.host because case is preserved and special chars allowed |
19 | 19 |
# must require trailing ? , to avoid needing login to view the page itself |
20 | 20 |
# must come before other redirects, because they lose the username |
21 |
RewriteCond %{THE_REQUEST} "\? \S+$"
|
|
21 |
RewriteCond %{THE_REQUEST} "[?&] \S+$"
|
|
22 | 22 |
RewriteRule ^ username_prefix.php [discardpath,last,noescape,qsappend] |
23 | 23 |
|
24 | 24 |
# remove www subdomain |
trunk/web/username_prefix.php | ||
---|---|---|
8 | 8 |
} |
9 | 9 |
else |
10 | 10 |
{ |
11 |
$url = $_SERVER["REQUEST_URI"];
|
|
11 |
$subpath = user2path($_SERVER["PHP_AUTH_USER"]);
|
|
12 | 12 |
header("Location: ".($_SERVER["PHP_AUTH_USER"] !== "" |
13 |
? $url/*ends in ? */.user2path($_SERVER["PHP_AUTH_USER"]) |
|
14 |
: rtrim($url, "?") # if user empty, just display page |
|
13 |
? ($_SERVER["QUERY_STRING"] !== "" |
|
14 |
? /*prepend to query string*/$_SERVER["SCRIPT_URL"] |
|
15 |
."?.".$subpath."&".rtrim($_SERVER["QUERY_STRING"], "&") |
|
16 |
: $_SERVER["REQUEST_URI"]/*ends in ? */.$subpath |
|
17 |
) |
|
18 |
: rtrim($_SERVER["REQUEST_URI"], "?") #user empty->just display page |
|
15 | 19 |
)); |
16 | 20 |
} |
17 | 21 |
?> |
Also available in: Unified diff
web/.htaccess, web/username_prefix.php: username-based prefix subpaths: support query strings in addition to paths