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 7978 aaronmk
RewriteRule ^.*$ %1/%2/$0 [last,nosubreq] # avoid infinite recursion
28 7976 aaronmk
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 7978 aaronmk
RewriteRule ^.*$ %1/$0 [last,nosubreq] # avoid infinite recursion
36 7966 aaronmk
37 7979 aaronmk
# translate dot-paths to dirs
38 7970 aaronmk
RewriteCond %{DOCUMENT_ROOT}/$1 -d [ornext]
39
RewriteCond %{DOCUMENT_ROOT}/$1 -l
40 7980 aaronmk
RewriteRule ^([^/.]*)\.(.*)$ $1/$2 [last]
41 7970 aaronmk
42 7979 aaronmk
# translate dash-paths to dirs
43 7977 aaronmk
RewriteCond %{DOCUMENT_ROOT}/$1 -d [ornext]
44
RewriteCond %{DOCUMENT_ROOT}/$1 -l
45 7980 aaronmk
RewriteRule ^([^/.-]*)-(.*)$ $1/$2 [last]
46 7977 aaronmk
47 7957 aaronmk
# non-filesystem paths
48 7973 aaronmk
ErrorDocument 404 /