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
# use separate lowercase version when available
21
RewriteCond %{DOCUMENT_ROOT}/$1 !-d
22
RewriteCond %{DOCUMENT_ROOT}/$1_ -d
23
RewriteRule ^([^/]*)(/.*)$ $1_$2 [discardpath,noescape]
24

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

    
31
## translate dotpaths (after the last /) to /-paths, e.g. d/a.[b.c] -> d/a/b.c/
32
# replace all unescaped . with / , e.g. a.[b.c] -> a/[b.c]
33
# remove any [] escape, e.g. a.b=[c.d] -> a/b=c.d (the ] must be at the end)
34
# if no . suffix, seal /-path so the filename 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 ^(.*/)?(?=.)([^./]*?)(?:\[([^\[\]/]*)\])?(?:\.([^/]*))?$ $1$2$3/$4 [discardpath,noescape,next]
38
	# discardpath: avoids infinite loop by not reappending PATH_INFO (filename)
39

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