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 7974 aaronmk
# don't rewrite existing paths
16
RewriteCond %{REQUEST_FILENAME} -d [ornext]
17
RewriteCond %{REQUEST_FILENAME} -f [ornext]
18
RewriteCond %{REQUEST_FILENAME} -l
19
RewriteRule ^.*$ - [last]
20
21 7976 aaronmk
# translate 2-level subdomain to prefix
22
RewriteCond %{HTTP_HOST} ^([^.]*)\.([^.]*)\..*$
23
RewriteCond %{DOCUMENT_ROOT}/%1/%2 -d [ornext]
24
RewriteCond %{DOCUMENT_ROOT}/%1/%2 -l
25
# this RewriteRule won't be re-run
26
RewriteCond %{DOCUMENT_ROOT}/%1/%2/.htaccess -f
27
RewriteRule ^.*$ %1/%2/$0 [nosubreq] # avoid infinite recursion
28
29
# translate 1-level subdomain to prefix
30 7975 aaronmk
RewriteCond %{HTTP_HOST} ^([^.]*)\..*$
31 7971 aaronmk
RewriteCond %{DOCUMENT_ROOT}/%1 -d [ornext]
32
RewriteCond %{DOCUMENT_ROOT}/%1 -l
33 7972 aaronmk
# this RewriteRule won't be re-run
34
RewriteCond %{DOCUMENT_ROOT}/%1/.htaccess -f
35 7969 aaronmk
RewriteRule ^.*$ %1/$0 [nosubreq] # avoid infinite recursion
36 7966 aaronmk
37 7977 aaronmk
# translate dot-path head to dir
38 7970 aaronmk
RewriteCond %{DOCUMENT_ROOT}/$1 -d [ornext]
39
RewriteCond %{DOCUMENT_ROOT}/$1 -l
40 7977 aaronmk
RewriteRule ^([^.]*)\.(.*)$ $1/$2 [last]
41 7970 aaronmk
42 7977 aaronmk
# translate dash-path head to dir
43
RewriteCond %{DOCUMENT_ROOT}/$1 -d [ornext]
44
RewriteCond %{DOCUMENT_ROOT}/$1 -l
45
RewriteRule ^([^.-]*)-(.*)$ $1/$2 [last]
46
47 7957 aaronmk
# non-filesystem paths
48 7973 aaronmk
ErrorDocument 404 /