1
|
#### URL resolution
|
2
|
|
3
|
DirectorySlash on
|
4
|
DirectoryIndex index.php
|
5
|
|
6
|
### mod_rewrite
|
7
|
|
8
|
RewriteEngine on
|
9
|
RewriteBase /
|
10
|
|
11
|
# remove www subdomain
|
12
|
RewriteCond %{HTTP_HOST} ^www\.(.*)$
|
13
|
RewriteRule ^.*$ http://%1/$0 [redirect]
|
14
|
|
15
|
# 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
|
# 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
|
# translate dot-paths to dirs
|
29
|
RewriteCond %{DOCUMENT_ROOT}/$1 -d [ornext]
|
30
|
RewriteCond %{DOCUMENT_ROOT}/$1 -l
|
31
|
RewriteRule ^([^.]*)\.(.*)$ $1/$2 [next]
|
32
|
# next: if match, repeat until no more replacements
|
33
|
|
34
|
# non-filesystem paths
|
35
|
ErrorDocument 404 /
|