1 |
7876
|
aaronmk
|
#### URL resolution
|
2 |
|
|
|
3 |
7889
|
aaronmk
|
DirectorySlash on
|
4 |
7949
|
aaronmk
|
DirectoryIndex index.php
|
5 |
7876
|
aaronmk
|
|
6 |
|
|
### mod_rewrite
|
7 |
|
|
|
8 |
7878
|
aaronmk
|
RewriteEngine on
|
9 |
8010
|
aaronmk
|
RewriteOptions inherit
|
10 |
7876
|
aaronmk
|
|
11 |
7959
|
aaronmk
|
# remove www subdomain
|
12 |
|
|
RewriteCond %{HTTP_HOST} ^www\.(.*)$
|
13 |
8013
|
aaronmk
|
RewriteRule ^.*$ http://%1/$0 [discardpath,noescape,last]
|
14 |
7959
|
aaronmk
|
|
15 |
7987
|
aaronmk
|
# translate subdomain to path
|
16 |
8022
|
aaronmk
|
RewriteCond %{HTTP_HOST} !=vegbiendev.nceas.ucsb.edu
|
17 |
|
|
RewriteCond %{HTTP_HOST} ^(.*)\.([^.]*\.[^.]*)$
|
18 |
|
|
RewriteRule ^.*$ http://%2/${subdomain2path:%1}/$0 [discardpath,noescape,last]
|
19 |
7987
|
aaronmk
|
|
20 |
8035
|
aaronmk
|
# 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 |
7997
|
aaronmk
|
# don't rewrite existing paths
|
26 |
|
|
RewriteCond %{REQUEST_FILENAME} -d [ornext]
|
27 |
|
|
RewriteCond %{REQUEST_FILENAME} -f [ornext]
|
28 |
|
|
RewriteCond %{REQUEST_FILENAME} -l
|
29 |
8011
|
aaronmk
|
RewriteRule ^.*$ - [discardpath,noescape,last]
|
30 |
7997
|
aaronmk
|
|
31 |
8041
|
aaronmk
|
# don't redirect subdir paths
|
32 |
|
|
RewriteCond %{DOCUMENT_ROOT}/$1 -d [ornext]
|
33 |
|
|
RewriteCond %{DOCUMENT_ROOT}/$1 -l
|
34 |
8045
|
aaronmk
|
RewriteRule ^([^/]+).*$ - [discardpath,noescape,last]
|
35 |
8041
|
aaronmk
|
|
36 |
|
|
# handle DirectoryIndex (this must be at this position in the rules)
|
37 |
|
|
RewriteRule ^(.*/)?index\.php$ $1 [discardpath,noescape]
|
38 |
|
|
|
39 |
8001
|
aaronmk
|
## 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 |
8028
|
aaronmk
|
# remove any [] escape, e.g. a.b=[c.d] -> a/b=c.d (the ] must be at the end)
|
42 |
8024
|
aaronmk
|
# 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 |
8031
|
aaronmk
|
RewriteRule ^(.*/)?(?=.)([^./]*?)(?:\[([^\[\]/]*)\])?(?:\.([^/]*))?$ $1$2$3/$4 [discardpath,noescape,next]
|
46 |
8029
|
aaronmk
|
# discardpath: avoids infinite loop by not reappending PATH_INFO (filename)
|
47 |
8001
|
aaronmk
|
|
48 |
8041
|
aaronmk
|
## specific to /
|
49 |
|
|
|
50 |
|
|
RewriteRule ^(?:(.*)/)?$ https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCore#$1 [discardpath,noescape,last]
|