Project

General

Profile

« Previous | Next » 

Revision 8011

web/main/.htaccess: RewriteRules: Added [discardpath,noescape] flags to all rules, because these are needed for correct interpretation of the replacement and should be the default setting. For some rules they may be optional, but it is better to include them on all rules to ensure there is never an unexpected effect from omitting them.

View differences:

.htaccess
10 10

  
11 11
# remove www subdomain
12 12
RewriteCond %{HTTP_HOST} ^www\.(.*)$
13
RewriteRule ^.*$ http://%1/$0 [redirect]
13
RewriteRule ^.*$ http://%1/$0 [discardpath,noescape,redirect]
14 14

  
15 15
# translate subdomain to path
16 16
RewriteCond expr "%{HTTP_HOST} != %{SERVER_NAME}"
17 17
RewriteCond %{HTTP_HOST} ^(.*)(\.[^.]*){2}$
18 18
RewriteCond ${subdomain2path:%1} ^([^/]*).*$
19 19
RewriteCond expr "! $0 -fnmatch '%1*'"
20
RewriteRule ^.*$ %0/$0 [last]
20
RewriteRule ^.*$ %0/$0 [discardpath,noescape,last]
21 21

  
22 22
# don't rewrite existing paths
23 23
RewriteCond %{REQUEST_FILENAME} -d [ornext]
24 24
RewriteCond %{REQUEST_FILENAME} -f [ornext]
25 25
RewriteCond %{REQUEST_FILENAME} -l
26
RewriteRule ^.*$ - [last]
26
RewriteRule ^.*$ - [discardpath,noescape,last]
27 27

  
28 28
## translate dotpaths (after the last /) to /-paths, e.g. d/a.[b.c] -> d/a/b.c/
29 29

  
30 30
# replace all unescaped . with / , e.g. a.[b.c] -> a/[b.c]
31
RewriteRule ^((?:.*/)?(?:[^.\[\]/]+|\[[^\[\]/]*\])+)\.([^/]+)$ $1/$2 [discardpath,next]
31
RewriteRule ^((?:.*/)?(?:[^.\[\]/]+|\[[^\[\]/]*\])+)\.([^/]+)$ $1/$2 [discardpath,noescape,next]
32 32
	# discardpath: avoids infinite loop with paths like a/b.c
33 33

  
34 34
# seal the /-path so the filename part is not reinterpreted as a dotpath
35 35
# e.g. a/[b.c] -> a/[b.c]/ so it doesn't become a/b/c after []-unescaping
36 36
# this is needed because mod_rewrite often runs the same rules again
37
RewriteRule ^.*[^/]$ $0/
37
RewriteRule ^.*[^/]$ $0/ [discardpath,noescape]
38 38

  
39 39
# remove all [] escapes (but leave empty []), e.g. a/[b.c]/ -> a/b.c/
40
RewriteRule ^(.*)\[([^\[\]]+)\](.*)$ $1$2$3 [discardpath,next]
40
RewriteRule ^(.*)\[([^\[\]]+)\](.*)$ $1$2$3 [discardpath,noescape,next]
41 41

  
42 42

  
43 43
# non-filesystem paths

Also available in: Unified diff