Project

General

Profile

1
#### URL resolution
2

    
3
DirectorySlash on
4
DirectoryIndex index.php
5

    
6
### mod_rewrite
7

    
8
RewriteEngine on
9
RewriteOptions inherit
10

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

    
15
# translate subdomain to path
16
RewriteCond %{HTTP_HOST} !=vegbiendev.nceas.ucsb.edu
17
RewriteCond %{HTTP_HOST} ^(.*)\.([^.]*\.[^.]*)$
18
RewriteRule ^.*$ http://%2/${subdomain2path:%1}/$0 [discardpath,noescape,last]
19

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

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

    
28
# replace all unescaped . with / , e.g. a.[b.c] -> a/[b.c]
29
# remove up to two [] escapes per dot-level, e.g. a.[b.c]=[d.e] -> a/b.c=d.e
30
RewriteCond $2 ^(.*)(?:\[([^\[\]]*)\](.*))?(?:\[([^\[\]]*)\](.*))?$
31
RewriteRule ^((?:.*/)?(?:[^.\[\]/]*|\[[^\[\]/]*\])*)\.([^/]*)$ $1/%1%2%3%4%5 [discardpath,noescape,next]
32
	# discardpath: avoids infinite loop with paths like a/b.c
33

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

    
39

    
40
# non-filesystem paths
41
ErrorDocument 404 /
(1-1/5)