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 7892 aaronmk
RewriteBase /
10 7876 aaronmk
11 7959 aaronmk
# remove www subdomain
12
RewriteCond %{HTTP_HOST} ^www\.(.*)$
13
RewriteRule ^.*$ http://%1/$0 [redirect]
14
15 7987 aaronmk
# translate subdomain to path
16
RewriteCond expr "%{HTTP_HOST} != %{SERVER_NAME}"
17
RewriteCond %{HTTP_HOST} ^(.*)(\.[^.]*){2}$
18
RewriteCond ${subdomain2path:%1} ^([^/]*).*$
19
RewriteCond expr "! $0 -fnmatch '%1*'"
20
RewriteRule ^.*$ %0/$0 [last]
21
22 7997 aaronmk
# don't rewrite existing paths
23
RewriteCond %{REQUEST_FILENAME} -d [ornext]
24
RewriteCond %{REQUEST_FILENAME} -f [ornext]
25
RewriteCond %{REQUEST_FILENAME} -l
26
RewriteRule ^.*$ - [last]
27
28 8000 aaronmk
# translate dotpaths to /-paths (the dotpath follows the last /)
29
# replace all unescaped . with /
30
RewriteRule ^((?:.*/)?(?:[^.\[\]/]+|\[[^\[\]/]*\])+)\.([^/]+)$ $1/$2 [discardpath,next]
31
	# discardpath: avoids infinite loop with paths like a/b.c
32
# seal the /-path so the filename part is not reinterpreted as a dotpath
33
RewriteRule ^.*[^/]$ $0/
34
# remove all [] escapes (but leave empty [])
35
RewriteRule ^(.*)\[([^\[\]]+)\](.*)$ $1$2$3 [discardpath,next]
36 7970 aaronmk
37 7957 aaronmk
# non-filesystem paths
38 7973 aaronmk
ErrorDocument 404 /