Project

General

Profile

« Previous | Next » 

Revision 13668

web/.htaccess, username_prefix.php: username-based prefix subpaths: don't require the // at the end , to avoid clutter. IMPORTANT: in order to access the home page after visiting a URL with a username, you must now append "." to the host ("vegpath.org.") (other pages are not affected by this problem). since vegpath.org is a URL shortener, this is a worthwhile tradeoff to avoid needing the // suffixes everywhere.

View differences:

trunk/web/.htaccess
28 28
RewriteCond %{QUERY_STRING} ^(@?)(.*)$
29 29
RewriteRule ^.*$ $0?%1&%2 [discardpath,noescape]
30 30

  
31
# handle username-based prefix subpaths of the form "subpath@host//path"
32
# supports multiple @ , nested . , & query str: a@b.c@url//?d&q -> url?b.c.a.d&q
31
# handle username-based prefix subpaths of the form "__@host" or "__@host?query"
32
# *note*: paths and subdomains are *not* supported when using usernames
33
# supports multiple @ , nested . , query str: a@b.c@host?d&q -> host.?b.c.a.d&q
33 34
# better than subpath.host because case is preserved and special chars allowed
34
# must require leading // , to avoid needing login to view the page itself
35
# **IMPORTANT**: to access the home page after visiting a URL with a username,
36
#  you must append . to the host (other pages are not affected by this problem)
35 37
# must come before external redirects, because they lose the username
36
RewriteCond %{THE_REQUEST} "\S+ //"
37
RewriteRule ^ username_prefix.php [discardpath,last,noescape,qsappend]
38
RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$
39
	# doesn't have subdomain & host doesn't end in . (which disables usernames)
40
RewriteCond %{REQUEST_URI} =/
41
	# doesn't have path (which disables usernames to avoid needing trailing . )
42
RewriteRule ^.*$ username_prefix.php [discardpath,last,noescape,qsappend]
38 43

  
39 44
# remove www subdomain
40 45
RewriteCond %{HTTP_HOST} ^www\.(.*)$
trunk/web/username_prefix.php
8 8
}
9 9
else
10 10
{
11
	$dest = $_SERVER["SCRIPT_URL"]."?";
11
	$dest = preg_replace('!\b/!', "./", $_SERVER["SCRIPT_URI"])."?";
12
		# append trailing . to host to prevent infinite redirect loop
12 13
	if ($_SERVER["PHP_AUTH_USER"] !== "") # prepend to query string
13 14
		$dest .= "."/*force dotpath*/.user2path($_SERVER["PHP_AUTH_USER"]);
14 15
	$dest .= $_SERVER["QUERY_STRING"];

Also available in: Unified diff