Project

General

Profile

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
# 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
# translate 2-level subdomain to prefix
22
RewriteCond %{HTTP_HOST} ^([^.]*)\.([^.]*)\..*$
23
RewriteCond %{DOCUMENT_ROOT}/%2/%1 -d [ornext]
24
RewriteCond %{DOCUMENT_ROOT}/%2/%1 -l
25
# this RewriteRule won't be re-run
26
RewriteCond %{DOCUMENT_ROOT}/%2/%1/.htaccess -f
27
RewriteRule ^.*$ %2/%1/$0 [last,nosubreq] # avoid infinite recursion
28

    
29
# translate 1-level subdomain to prefix
30
RewriteCond %{HTTP_HOST} ^([^.]*)\..*$
31
RewriteCond %{DOCUMENT_ROOT}/%1 -d [ornext]
32
RewriteCond %{DOCUMENT_ROOT}/%1 -l
33
# this RewriteRule won't be re-run
34
RewriteCond %{DOCUMENT_ROOT}/%1/.htaccess -f
35
RewriteRule ^.*$ %1/$0 [last,nosubreq] # avoid infinite recursion
36

    
37
# translate dot-paths to dirs
38
RewriteCond %{DOCUMENT_ROOT}/$1 -d [ornext]
39
RewriteCond %{DOCUMENT_ROOT}/$1 -l
40
RewriteRule ^([^/.]*)\.(.*)$ $1/$2 [last]
41

    
42
# non-filesystem paths
43
ErrorDocument 404 /
(1-1/5)