Project

General

Profile

1
#### URL resolution
2

    
3
Options +FollowSymLinks
4

    
5
DirectorySlash on
6
DirectoryIndex index.php
7

    
8
### mod_rewrite
9

    
10
RewriteEngine on
11
RewriteOptions inherit
12

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

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

    
22
# use separate lowercase version when available
23
RewriteCond %{DOCUMENT_ROOT}/$1 !-d
24
RewriteCond .$1 ^.*$
25
RewriteCond %{DOCUMENT_ROOT}/%0 -d
26
RewriteRule ^([^/]*)(/.*)$ %0$2 [discardpath,noescape]
27

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

    
34
# don't redirect subdir paths
35
RewriteCond %{DOCUMENT_ROOT}/$1 -d [ornext]
36
RewriteCond %{DOCUMENT_ROOT}/$1 -l
37
RewriteRule ^([^/]+).*$ - [discardpath,noescape,last]
38

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

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

    
51
## specific to /
52

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