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 |
7992
|
aaronmk
|
# translate dot-paths to dirs when they exist in the filesystem
|
23 |
|
|
# each subdir Redirect directive needs a corresponding tree of (empty) dirs
|
24 |
7970
|
aaronmk
|
RewriteCond %{DOCUMENT_ROOT}/$1 -d [ornext]
|
25 |
|
|
RewriteCond %{DOCUMENT_ROOT}/$1 -l
|
26 |
7988
|
aaronmk
|
RewriteRule ^([^.]*)\.(.*)$ $1/$2 [next]
|
27 |
|
|
# next: if match, repeat until no more replacements
|
28 |
7970
|
aaronmk
|
|
29 |
7957
|
aaronmk
|
# non-filesystem paths
|
30 |
7973
|
aaronmk
|
ErrorDocument 404 /
|