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
# don't redirect subdir paths
32
RewriteCond %{DOCUMENT_ROOT}/$1 -d [ornext]
33
RewriteCond %{DOCUMENT_ROOT}/$1 -l
34
RewriteRule ^([^/]+).*$ - [discardpath,noescape,last]
35

    
36
# handle DirectoryIndex (this must be at this position in the rules)
37
RewriteRule ^(.*/)?index\.php$ $1 [discardpath,noescape]
38

    
39
## translate dotpaths (after the last /) to /-paths, e.g. d/a.[b.c] -> d/a/b.c/
40
# replace all unescaped . with / , e.g. a.[b.c] -> a/[b.c]
41
# remove any [] escape, e.g. a.b=[c.d] -> a/b=c.d (the ] must be at the end)
42
# if no . suffix, seal /-path so the filename is not reinterpreted as a dotpath
43
# e.g. a/[b.c] -> a/[b.c]/ so it doesn't become a/b/c after []-unescaping
44
# this is needed because mod_rewrite often runs the same rules again
45
RewriteRule ^(.*/)?(?=.)([^./]*?)(?:\[([^\[\]/]*)\])?(?:\.([^/]*))?$ $1$2$3/$4 [discardpath,noescape,next]
46
	# discardpath: avoids infinite loop by not reappending PATH_INFO (filename)
47

    
48
## specific to /
49

    
50
RewriteRule ^(?:(.*)/)?$ https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCore#$1 [discardpath,noescape,last]
(1-1/10)