Project

General

Profile

« Previous | Next » 

Revision 13622

web/.htaccess, username_prefix.php: username-based prefix subpaths: support dotpath in query string (which will be appended verbatim to the prefix). use "__?@__" instead of "__?__&" to signal username-based prefix, so that the query string does not end in a dangling & .

View differences:

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?" or "__?__&"
17
# supports multiple @ , nested . , & query str: a@b.c@url?k=v& -> url?b.c.a&k=v
16
# handle username-based prefix subpaths of the form "subpath@url?" or "__?@__"
17
# supports multiple @ , nested . , & query str: a@b.c@url?@.d&q -> url?b.c.a.d&q
18
# ( @ is effectively a placeholder for the decoded username prefix)
18 19
# better than subpath.host because case is preserved and special chars allowed
19 20
# must require trailing ? , to avoid needing login to view the page itself
20 21
# must come before other redirects, because they lose the username
21
RewriteCond %{THE_REQUEST} "[?&] \S+$"
22
RewriteCond %{THE_REQUEST} "\? \S+$" [ornext]
23
RewriteCond %{QUERY_STRING} ^@
22 24
RewriteRule ^ username_prefix.php [discardpath,last,noescape,qsappend]
23 25

  
24 26
# remove www subdomain
trunk/web/username_prefix.php
12 12
	header("Location: ".($_SERVER["PHP_AUTH_USER"] !== ""
13 13
			? ($_SERVER["QUERY_STRING"] !== ""
14 14
				? /*prepend to query string*/$_SERVER["SCRIPT_URL"]
15
					."?.".$subpath."&".rtrim($_SERVER["QUERY_STRING"], "&")
15
					."?.".$subpath.ltrim($_SERVER["QUERY_STRING"], "@")
16 16
				: $_SERVER["REQUEST_URI"]/*ends in ? */.$subpath
17 17
			)
18 18
			: rtrim($_SERVER["REQUEST_URI"], "?") #user empty->just display page

Also available in: Unified diff