Project

General

Profile

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 7997 aaronmk
# don't rewrite existing paths
21
RewriteCond %{REQUEST_FILENAME} -d [ornext]
22
RewriteCond %{REQUEST_FILENAME} -f [ornext]
23
RewriteCond %{REQUEST_FILENAME} -l
24 8011 aaronmk
RewriteRule ^.*$ - [discardpath,noescape,last]
25 7997 aaronmk
26 8001 aaronmk
## translate dotpaths (after the last /) to /-paths, e.g. d/a.[b.c] -> d/a/b.c/
27
# replace all unescaped . with / , e.g. a.[b.c] -> a/[b.c]
28 8026 aaronmk
# remove up to one [] escape per dot-level, e.g. a.b=[c.d] -> a/b=c.d
29
RewriteCond $2 ^([^\[\]]*)(?:\[([^\[\]]*)\]([^\[\]]*))?$
30 8024 aaronmk
# if no . suffix, seal /-path so the filename is not reinterpreted as a dotpath
31
# e.g. a/[b.c] -> a/[b.c]/ so it doesn't become a/b/c after []-unescaping
32
# this is needed because mod_rewrite often runs the same rules again
33 8027 aaronmk
RewriteRule ^(.*/)?((?=.)(?:[^.\[\]/]*|\[[^\[\]/]*\])*)(?:\.([^/]*))?$ $1%1%2%3%4%5/$3 [discardpath,noescape,next]
34 8000 aaronmk
	# discardpath: avoids infinite loop with paths like a/b.c
35 8001 aaronmk
36 7957 aaronmk
# non-filesystem paths
37 8025 aaronmk
ErrorDocument 404 /