1 |
7876
|
aaronmk
|
#### URL resolution
|
2 |
|
|
|
3 |
8397
|
aaronmk
|
Options +FollowSymLinks +Indexes +MultiViews
|
4 |
8055
|
aaronmk
|
|
5 |
8402
|
aaronmk
|
DirectorySlash off
|
6 |
8396
|
aaronmk
|
DirectoryIndex index
|
7 |
7876
|
aaronmk
|
|
8 |
|
|
### mod_rewrite
|
9 |
|
|
|
10 |
7878
|
aaronmk
|
RewriteEngine on
|
11 |
8405
|
aaronmk
|
RewriteOptions AllowNoSlash
|
12 |
7876
|
aaronmk
|
|
13 |
8443
|
aaronmk
|
SetEnvIf Request_URI ^ innermost_dir=/
|
14 |
|
|
|
15 |
7959
|
aaronmk
|
# remove www subdomain
|
16 |
|
|
RewriteCond %{HTTP_HOST} ^www\.(.*)$
|
17 |
8450
|
aaronmk
|
RewriteRule ^.*$ %{REQUEST_SCHEME}://%1%{REQUEST_URI} [discardpath,noescape,last,qsappend]
|
18 |
7959
|
aaronmk
|
|
19 |
8178
|
aaronmk
|
# remove linewraps used to create a newline for Google spreadsheets
|
20 |
8450
|
aaronmk
|
RewriteRule ^_-(.*)$ /$1 [discardpath,noescape,last,redirect,qsappend]
|
21 |
8178
|
aaronmk
|
|
22 |
8431
|
aaronmk
|
# set REQUEST_URI_NO_SLASH
|
23 |
|
|
RewriteCond %{REQUEST_URI} ^/$ [ornext]
|
24 |
|
|
RewriteCond %{REQUEST_URI} ^(.*)$
|
25 |
8441
|
aaronmk
|
RewriteRule ^ - [env=REQUEST_URI_no_/:%1]
|
26 |
8431
|
aaronmk
|
|
27 |
7987
|
aaronmk
|
# translate subdomain to path
|
28 |
8022
|
aaronmk
|
RewriteCond %{HTTP_HOST} !=vegbiendev.nceas.ucsb.edu
|
29 |
|
|
RewriteCond %{HTTP_HOST} ^(.*)\.([^.]*\.[^.]*)$
|
30 |
8450
|
aaronmk
|
RewriteRule ^.*$ %{REQUEST_SCHEME}://%2/${subdomain2path:%1}%{ENV:REQUEST_URI_no_/} [discardpath,noescape,last,qsappend]
|
31 |
7987
|
aaronmk
|
|
32 |
8035
|
aaronmk
|
# use separate lowercase version when available
|
33 |
8443
|
aaronmk
|
RewriteCond %{ENV:innermost_dir} =/
|
34 |
8035
|
aaronmk
|
RewriteCond %{DOCUMENT_ROOT}/$1 !-d
|
35 |
8058
|
aaronmk
|
RewriteCond .${tolower:$1} ^.*$
|
36 |
8057
|
aaronmk
|
RewriteCond %{DOCUMENT_ROOT}/%0 -d
|
37 |
8450
|
aaronmk
|
RewriteRule ^([^/]*)(.*)$ %0$2 [discardpath,noescape,last,qsappend]
|
38 |
8389
|
aaronmk
|
# last: rewrite in the new subdir instead of applying this dir's rules
|
39 |
8035
|
aaronmk
|
|
40 |
8491
|
aaronmk
|
# parse dotpath in query string (having a . before any = )
|
41 |
|
|
# you can prepend . to force a dotpath, or & to force a query param
|
42 |
8450
|
aaronmk
|
RewriteRule ^dotpath - [discardpath,noescape,last,qsappend]
|
43 |
8491
|
aaronmk
|
RewriteCond %{QUERY_STRING} ^[^&]+
|
44 |
|
|
RewriteCond %0 ^[^=]*(?:\.|$)
|
45 |
8399
|
aaronmk
|
RewriteCond %{REQUEST_URI} ^(.*?)(?:/index(?:\.\w+)?)?$
|
46 |
8450
|
aaronmk
|
RewriteRule ^.*$ /dotpath%1 [discardpath,noescape,last,qsappend]
|
47 |
7997
|
aaronmk
|
|
48 |
8481
|
aaronmk
|
# don't rewrite existing dirs with trailing /
|
49 |
|
|
RewriteCond %{REQUEST_FILENAME} -d
|
50 |
|
|
RewriteRule ^.+/$ - [discardpath,noescape,last,qsappend]
|
51 |
|
|
|
52 |
|
|
# don't rewrite existing files
|
53 |
8363
|
aaronmk
|
RewriteCond %{REQUEST_FILENAME} -f
|
54 |
8481
|
aaronmk
|
RewriteRule ^.+$ - [discardpath,noescape,last,qsappend]
|
55 |
8041
|
aaronmk
|
|
56 |
8483
|
aaronmk
|
# auto-add trailing / unless has an .htaccess with possible redirect
|
57 |
|
|
RewriteCond %{REQUEST_FILENAME} -d
|
58 |
|
|
RewriteCond %{REQUEST_FILENAME}/.htaccess !-f
|
59 |
|
|
RewriteRule ^.+$ %{REQUEST_URI}/ [discardpath,noescape,last,redirect,qsappend]
|
60 |
8482
|
aaronmk
|
|
61 |
8447
|
aaronmk
|
# handle DirectoryIndex subrequests when there is no DirectoryIndex
|
62 |
|
|
# use -F subrequest so that MultiViews auto-appends any extension
|
63 |
|
|
RewriteCond %{REQUEST_FILENAME} !-F
|
64 |
8450
|
aaronmk
|
RewriteRule ^(.*/)?index$ $1 [discardpath,noescape,qsappend]
|
65 |
8447
|
aaronmk
|
|
66 |
8496
|
aaronmk
|
# prepend dir name if it's part of the filename (e.g. dir/file -> dir/dir.file)
|
67 |
|
|
# works only if dir supports relative redirects and sets %{ENV:innermost_dir}
|
68 |
|
|
RewriteCond %{REQUEST_FILENAME} ^(.*/)?(.+?)$
|
69 |
8498
|
aaronmk
|
RewriteCond %1%{ENV:innermost_dir}.%2 -F
|
70 |
8496
|
aaronmk
|
RewriteRule ^(?!/)(.*/)?(.+?)$ $1%{ENV:innermost_dir}.$2 [discardpath,noescape,last,redirect,qsappend]
|
71 |
|
|
|
72 |
8041
|
aaronmk
|
## specific to /
|
73 |
|
|
|
74 |
8443
|
aaronmk
|
RewriteCond %{ENV:innermost_dir} =/
|
75 |
8450
|
aaronmk
|
RewriteRule ^.+$ /VegCore/$0 [discardpath,noescape,last,qsappend]
|