Project

General

Profile

« Previous | Next » 

Revision 8030

web/main/.htaccess: translate dotpaths: Inline the [] escape regexp into the main regexp, because it is now approximately the same length as the []-matching portion of the main regexp and this greatly simplifies the code by removing the extra RewriteCond. Note that the translation rule is now a plain regexp (run repeatedly until no match), which can be used in any programming language that supports Perl-compatible regular expressions, not just mod_rewrite.

View differences:

.htaccess
26 26
## translate dotpaths (after the last /) to /-paths, e.g. d/a.[b.c] -> d/a/b.c/
27 27
# replace all unescaped . with / , e.g. a.[b.c] -> a/[b.c]
28 28
# remove any [] escape, e.g. a.b=[c.d] -> a/b=c.d (the ] must be at the end)
29
RewriteCond $2 ^([^\[\]]*)(?:\[([^\[\]]*)\])?$
30 29
# if no . suffix, seal /-path so the filename is not reinterpreted as a dotpath
31 30
# e.g. a/[b.c] -> a/[b.c]/ so it doesn't become a/b/c after []-unescaping
32 31
# this is needed because mod_rewrite often runs the same rules again
33
RewriteRule ^(.*/)?((?=.)(?:[^.\[\]/]*|\[[^\[\]/]*\])*)(?:\.([^/]*))?$ $1%1%2/$3 [discardpath,noescape,next]
32
RewriteRule ^(.*/)?(?=.)([^.\[\]/]*)(?:\[([^\[\]/]*)\])?(?:\.([^/]*))?$ $1$2$3/$4 [discardpath,noescape,next]
34 33
	# discardpath: avoids infinite loop by not reappending PATH_INFO (filename)
35 34

  
36 35
# non-filesystem paths

Also available in: Unified diff