1 |
7876
|
aaronmk
|
#### URL resolution
|
2 |
|
|
|
3 |
8055
|
aaronmk
|
Options +FollowSymLinks
|
4 |
|
|
|
5 |
7889
|
aaronmk
|
DirectorySlash on
|
6 |
7949
|
aaronmk
|
DirectoryIndex index.php
|
7 |
7876
|
aaronmk
|
|
8 |
|
|
### mod_rewrite
|
9 |
|
|
|
10 |
7878
|
aaronmk
|
RewriteEngine on
|
11 |
8010
|
aaronmk
|
RewriteOptions inherit
|
12 |
7876
|
aaronmk
|
|
13 |
7959
|
aaronmk
|
# remove www subdomain
|
14 |
|
|
RewriteCond %{HTTP_HOST} ^www\.(.*)$
|
15 |
8013
|
aaronmk
|
RewriteRule ^.*$ http://%1/$0 [discardpath,noescape,last]
|
16 |
7959
|
aaronmk
|
|
17 |
8178
|
aaronmk
|
# remove linewraps used to create a newline for Google spreadsheets
|
18 |
|
|
RewriteRule ^_-(.*)$ /$1 [discardpath,noescape,last,redirect]
|
19 |
|
|
|
20 |
7987
|
aaronmk
|
# translate subdomain to path
|
21 |
8022
|
aaronmk
|
RewriteCond %{HTTP_HOST} !=vegbiendev.nceas.ucsb.edu
|
22 |
|
|
RewriteCond %{HTTP_HOST} ^(.*)\.([^.]*\.[^.]*)$
|
23 |
|
|
RewriteRule ^.*$ http://%2/${subdomain2path:%1}/$0 [discardpath,noescape,last]
|
24 |
7987
|
aaronmk
|
|
25 |
8035
|
aaronmk
|
# use separate lowercase version when available
|
26 |
|
|
RewriteCond %{DOCUMENT_ROOT}/$1 !-d
|
27 |
8058
|
aaronmk
|
RewriteCond .${tolower:$1} ^.*$
|
28 |
8057
|
aaronmk
|
RewriteCond %{DOCUMENT_ROOT}/%0 -d
|
29 |
|
|
RewriteRule ^([^/]*)(/.*)$ %0$2 [discardpath,noescape]
|
30 |
8035
|
aaronmk
|
|
31 |
7997
|
aaronmk
|
# don't rewrite existing paths
|
32 |
|
|
RewriteCond %{REQUEST_FILENAME} -d [ornext]
|
33 |
8060
|
aaronmk
|
RewriteCond %{REQUEST_FILENAME} -f
|
34 |
8011
|
aaronmk
|
RewriteRule ^.*$ - [discardpath,noescape,last]
|
35 |
7997
|
aaronmk
|
|
36 |
8041
|
aaronmk
|
# don't redirect subdir paths
|
37 |
8060
|
aaronmk
|
RewriteCond %{DOCUMENT_ROOT}/$1 -d
|
38 |
8045
|
aaronmk
|
RewriteRule ^([^/]+).*$ - [discardpath,noescape,last]
|
39 |
8041
|
aaronmk
|
|
40 |
|
|
# handle DirectoryIndex (this must be at this position in the rules)
|
41 |
|
|
RewriteRule ^(.*/)?index\.php$ $1 [discardpath,noescape]
|
42 |
|
|
|
43 |
8001
|
aaronmk
|
## 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 |
8028
|
aaronmk
|
# remove any [] escape, e.g. a.b=[c.d] -> a/b=c.d (the ] must be at the end)
|
46 |
8024
|
aaronmk
|
# 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 |
8056
|
aaronmk
|
RewriteRule ^(.*/)?(?=.)(\.?[^./]*?)(?:\[([^\[\]/]*)\])?(?:\.([^/]*))?$ $1$2$3/$4 [discardpath,noescape,next]
|
50 |
8029
|
aaronmk
|
# discardpath: avoids infinite loop by not reappending PATH_INFO (filename)
|
51 |
8001
|
aaronmk
|
|
52 |
8041
|
aaronmk
|
## specific to /
|
53 |
|
|
|
54 |
|
|
RewriteRule ^(?:(.*)/)?$ https://projects.nceas.ucsb.edu/nceas/projects/bien/wiki/VegCore#$1 [discardpath,noescape,last]
|