1 |
7876
|
aaronmk
|
#### URL resolution
|
2 |
|
|
|
3 |
8397
|
aaronmk
|
Options +FollowSymLinks +Indexes +MultiViews
|
4 |
8055
|
aaronmk
|
|
5 |
8402
|
aaronmk
|
DirectorySlash off
|
6 |
9602
|
aaronmk
|
DirectoryIndex disabled
|
7 |
|
|
# index.* is instead supported by "redirect to index.*" RewriteRule
|
8 |
7876
|
aaronmk
|
|
9 |
|
|
### mod_rewrite
|
10 |
|
|
|
11 |
7878
|
aaronmk
|
RewriteEngine on
|
12 |
8405
|
aaronmk
|
RewriteOptions AllowNoSlash
|
13 |
7876
|
aaronmk
|
|
14 |
8443
|
aaronmk
|
SetEnvIf Request_URI ^ innermost_dir=/
|
15 |
|
|
|
16 |
13628
|
aaronmk
|
# auto-detect dotpath in query string (having a . or & before any = )
|
17 |
|
|
# you can prepend . to force a dotpath, or & to force a query param
|
18 |
|
|
# must come before username prefix parsing, because it requires the leading "."
|
19 |
|
|
RewriteCond %{QUERY_STRING} ^(?!@?[.&]).+$
|
20 |
|
|
# . not already prepended, does not start with & , and non-empty
|
21 |
|
|
RewriteCond %{QUERY_STRING} ^@?[^=]*(?:[.&]|$)
|
22 |
|
|
# . or & before any =
|
23 |
|
|
RewriteCond %{QUERY_STRING} ^(@?)(.*)$
|
24 |
|
|
RewriteRule ^.*$ $0?%1.%2 [discardpath,noescape]
|
25 |
|
|
|
26 |
13622
|
aaronmk
|
# handle username-based prefix subpaths of the form "subpath@url?" or "__?@__"
|
27 |
|
|
# supports multiple @ , nested . , & query str: a@b.c@url?@.d&q -> url?b.c.a.d&q
|
28 |
|
|
# ( @ is effectively a placeholder for the decoded username prefix)
|
29 |
13615
|
aaronmk
|
# better than subpath.host because case is preserved and special chars allowed
|
30 |
|
|
# must require trailing ? , to avoid needing login to view the page itself
|
31 |
13628
|
aaronmk
|
# must come before external redirects, because they lose the username
|
32 |
13622
|
aaronmk
|
RewriteCond %{THE_REQUEST} "\? \S+$" [ornext]
|
33 |
|
|
RewriteCond %{QUERY_STRING} ^@
|
34 |
13615
|
aaronmk
|
RewriteRule ^ username_prefix.php [discardpath,last,noescape,qsappend]
|
35 |
|
|
|
36 |
7959
|
aaronmk
|
# remove www subdomain
|
37 |
|
|
RewriteCond %{HTTP_HOST} ^www\.(.*)$
|
38 |
8507
|
aaronmk
|
RewriteRule ^.*$ %{REQUEST_SCHEME}://%1%{REQUEST_URI} [discardpath,last,noescape,qsappend]
|
39 |
7959
|
aaronmk
|
|
40 |
8178
|
aaronmk
|
# remove linewraps used to create a newline for Google spreadsheets
|
41 |
8507
|
aaronmk
|
RewriteRule ^_-(.*)$ /$1 [discardpath,last,noescape,qsappend,redirect]
|
42 |
8178
|
aaronmk
|
|
43 |
8503
|
aaronmk
|
## translate subdomain to path
|
44 |
8504
|
aaronmk
|
# set REQUEST_URI_no_extra_/
|
45 |
8502
|
aaronmk
|
RewriteCond %{REQUEST_URI} ^(?:/|(.*))$
|
46 |
8504
|
aaronmk
|
RewriteRule ^ - [env=REQUEST_URI_no_extra_/:%1]
|
47 |
8503
|
aaronmk
|
# translate
|
48 |
8022
|
aaronmk
|
RewriteCond %{HTTP_HOST} !=vegbiendev.nceas.ucsb.edu
|
49 |
|
|
RewriteCond %{HTTP_HOST} ^(.*)\.([^.]*\.[^.]*)$
|
50 |
8507
|
aaronmk
|
RewriteRule ^.*$ %{REQUEST_SCHEME}://%2/${subdomain2path:%1}%{ENV:REQUEST_URI_no_extra_/} [discardpath,last,noescape,qsappend]
|
51 |
7987
|
aaronmk
|
|
52 |
8035
|
aaronmk
|
# use separate lowercase version when available
|
53 |
8443
|
aaronmk
|
RewriteCond %{ENV:innermost_dir} =/
|
54 |
8035
|
aaronmk
|
RewriteCond %{DOCUMENT_ROOT}/$1 !-d
|
55 |
8058
|
aaronmk
|
RewriteCond .${tolower:$1} ^.*$
|
56 |
8057
|
aaronmk
|
RewriteCond %{DOCUMENT_ROOT}/%0 -d
|
57 |
8507
|
aaronmk
|
RewriteRule ^([^/]*)(.*)$ %0$2 [discardpath,last,noescape,qsappend]
|
58 |
8389
|
aaronmk
|
# last: rewrite in the new subdir instead of applying this dir's rules
|
59 |
8035
|
aaronmk
|
|
60 |
8505
|
aaronmk
|
## parse dotpath in query string
|
61 |
10612
|
aaronmk
|
# make dotpath replacement start with ./ instead of /
|
62 |
|
|
RewriteCond %{QUERY_STRING} ^\.
|
63 |
|
|
RewriteRule ^$ . [discardpath,noescape,qsappend]
|
64 |
8505
|
aaronmk
|
# parse dotpath levels repeatedly in QUERY_STRING
|
65 |
|
|
RewriteCond %{QUERY_STRING} ^\.([^./&]*?)(?:\[([^\[\]/&]*)\])?([.&].*)?$
|
66 |
|
|
RewriteRule ^(.*?)(?:/(?:index(?:\.\w+)?)?)?$ $1/%1%2?%3 [discardpath,noescape,next,env=needs_redirect:1]
|
67 |
|
|
# redirect so REQUEST_URI is populated from REQUEST_FILENAME
|
68 |
|
|
RewriteCond %{ENV:needs_redirect} !=""
|
69 |
10611
|
aaronmk
|
RewriteRule ^ - [discardpath,last,noescape,qsappend,redirect]
|
70 |
|
|
# - uses REQUEST_FILENAME as redirect dest instead of empty REQUEST_URI
|
71 |
7997
|
aaronmk
|
|
72 |
9612
|
aaronmk
|
# <dir>/all forces mod_autoindex listing
|
73 |
|
|
RewriteRule ^(.*/)?all$ $1 [discardpath,last,noescape,qsappend,env=mod_autoindex_listing:1]
|
74 |
|
|
|
75 |
|
|
# for dirs, redirect to index.* unless mod_autoindex listing was requested
|
76 |
13306
|
aaronmk
|
# can't use "index" b/c MultiViews doesn't support that filename in Ubuntu 14.04
|
77 |
13304
|
aaronmk
|
RewriteCond %{REQUEST_FILENAME}index.php -F
|
78 |
9612
|
aaronmk
|
# use -F subrequest so that MultiViews auto-appends any extension
|
79 |
|
|
RewriteCond %{ENV:REDIRECT_mod_autoindex_listing} =""
|
80 |
13304
|
aaronmk
|
RewriteRule ^(.*/)?$ $1index.php [discardpath,last,noescape,qsappend]
|
81 |
|
|
RewriteCond %{REQUEST_FILENAME}index.htm -F
|
82 |
|
|
# use -F subrequest so that MultiViews auto-appends any extension
|
83 |
|
|
RewriteCond %{ENV:REDIRECT_mod_autoindex_listing} =""
|
84 |
|
|
RewriteRule ^(.*/)?$ $1index.htm [discardpath,last,noescape,qsappend]
|
85 |
9612
|
aaronmk
|
|
86 |
8481
|
aaronmk
|
# don't rewrite existing dirs with trailing /
|
87 |
|
|
RewriteCond %{REQUEST_FILENAME} -d
|
88 |
8507
|
aaronmk
|
RewriteRule ^.+/$ - [discardpath,last,noescape,qsappend]
|
89 |
8481
|
aaronmk
|
|
90 |
|
|
# don't rewrite existing files
|
91 |
8363
|
aaronmk
|
RewriteCond %{REQUEST_FILENAME} -f
|
92 |
8507
|
aaronmk
|
RewriteRule ^.+$ - [discardpath,last,noescape,qsappend]
|
93 |
8041
|
aaronmk
|
|
94 |
8483
|
aaronmk
|
# auto-add trailing / unless has an .htaccess with possible redirect
|
95 |
|
|
RewriteCond %{REQUEST_FILENAME} -d
|
96 |
|
|
RewriteCond %{REQUEST_FILENAME}/.htaccess !-f
|
97 |
8507
|
aaronmk
|
RewriteRule ^.+$ %{REQUEST_URI}/ [discardpath,last,noescape,qsappend,redirect]
|
98 |
8482
|
aaronmk
|
|
99 |
8496
|
aaronmk
|
# prepend dir name if it's part of the filename (e.g. dir/file -> dir/dir.file)
|
100 |
|
|
# works only if dir supports relative redirects and sets %{ENV:innermost_dir}
|
101 |
|
|
RewriteCond %{REQUEST_FILENAME} ^(.*/)?(.+?)$
|
102 |
8498
|
aaronmk
|
RewriteCond %1%{ENV:innermost_dir}.%2 -F
|
103 |
8507
|
aaronmk
|
RewriteRule ^(?!/)(.*/)?(.+?)$ $1%{ENV:innermost_dir}.$2 [discardpath,last,noescape,qsappend,redirect]
|
104 |
8496
|
aaronmk
|
|
105 |
8041
|
aaronmk
|
## specific to /
|
106 |
|
|
|
107 |
8443
|
aaronmk
|
RewriteCond %{ENV:innermost_dir} =/
|
108 |
8507
|
aaronmk
|
RewriteRule ^.+$ /VegCore/$0 [discardpath,last,noescape,qsappend]
|
109 |
9604
|
aaronmk
|
|
110 |
|
|
|
111 |
|
|
#### directory indexing
|
112 |
|
|
|
113 |
|
|
### mod_autoindex
|
114 |
|
|
|
115 |
11034
|
aaronmk
|
IndexOptions +FoldersFirst +HTMLTable +IconsAreLinks +IgnoreCase +TrackModified +VersionSort +XHTML
|
116 |
9609
|
aaronmk
|
IndexOrderDefault Ascending Description
|
117 |
9608
|
aaronmk
|
|
118 |
11039
|
aaronmk
|
IndexStyleSheet /main.css
|
119 |
|
|
IndexHeadInsert '<div><i>Note that some listed files are not web-accessible. They will produce a "Forbidden" error when clicked.</i></div>'
|
120 |
11649
|
aaronmk
|
|
121 |
|
|
IndexIgnoreReset on
|
122 |
|
|
IndexIgnore .svn
|