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
|
# remove linewraps used to create a newline for Google spreadsheets
|
18
|
RewriteRule ^_-(.*)$ /$1 [discardpath,noescape,last,redirect]
|
19
|
|
20
|
# translate subdomain to path
|
21
|
RewriteCond %{HTTP_HOST} !=vegbiendev.nceas.ucsb.edu
|
22
|
RewriteCond %{HTTP_HOST} ^(.*)\.([^.]*\.[^.]*)$
|
23
|
RewriteRule ^.*$ http://%2/${subdomain2path:%1}/$0 [discardpath,noescape,last]
|
24
|
|
25
|
# use separate lowercase version when available
|
26
|
RewriteCond %{DOCUMENT_ROOT}/$1 !-d
|
27
|
RewriteCond .${tolower:$1} ^.*$
|
28
|
RewriteCond %{DOCUMENT_ROOT}/%0 -d
|
29
|
RewriteRule ^([^/]*)(/.*)$ %0$2 [discardpath,noescape]
|
30
|
|
31
|
# don't rewrite existing paths
|
32
|
RewriteCond %{REQUEST_FILENAME} -d [ornext]
|
33
|
RewriteCond %{REQUEST_FILENAME} -f
|
34
|
RewriteRule ^.*$ - [discardpath,noescape,last]
|
35
|
|
36
|
# don't redirect subdir paths
|
37
|
RewriteCond %{DOCUMENT_ROOT}/$1 -d
|
38
|
RewriteRule ^([^/]+).*$ - [discardpath,noescape,last]
|
39
|
|
40
|
# handle DirectoryIndex (this must be at this position in the rules)
|
41
|
RewriteRule ^(.*/)?index\.php$ $1 [discardpath,noescape]
|
42
|
|
43
|
## translate dotpaths (after the last /) to /-paths, e.g. d/a.[b.c] -> d/a/b.c/
|
44
|
# replace all unescaped . with / , e.g. a.[b.c] -> a/[b.c]
|
45
|
# remove any [] escape, e.g. a.b=[c.d] -> a/b=c.d (the ] must be at the end)
|
46
|
# if no . suffix, seal /-path so the filename is not reinterpreted as a dotpath
|
47
|
# e.g. a/[b.c] -> a/[b.c]/ so it doesn't become a/b/c after []-unescaping
|
48
|
# this is needed because mod_rewrite often runs the same rules again
|
49
|
RewriteRule ^(.*/)?(?=.)(\.?[^./]*?)(?:\[([^\[\]/]*)\])?(?:\.([^/]*))?$ $1$2$3/$4 [discardpath,noescape,next]
|
50
|
# discardpath: avoids infinite loop by not reappending PATH_INFO (filename)
|
51
|
|
52
|
## specific to /
|
53
|
|
54
|
RewriteRule ^(?:(.*)/)?$ https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCore#$1 [discardpath,noescape,last]
|