Project

General

Profile

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 7959 aaronmk
# remove www subdomain
17
RewriteCond %{HTTP_HOST} ^www\.(.*)$
18 8507 aaronmk
RewriteRule ^.*$ %{REQUEST_SCHEME}://%1%{REQUEST_URI} [discardpath,last,noescape,qsappend]
19 7959 aaronmk
20 8178 aaronmk
# remove linewraps used to create a newline for Google spreadsheets
21 8507 aaronmk
RewriteRule ^_-(.*)$ /$1 [discardpath,last,noescape,qsappend,redirect]
22 8178 aaronmk
23 8503 aaronmk
## translate subdomain to path
24 8504 aaronmk
# set REQUEST_URI_no_extra_/
25 8502 aaronmk
RewriteCond %{REQUEST_URI} ^(?:/|(.*))$
26 8504 aaronmk
RewriteRule ^ - [env=REQUEST_URI_no_extra_/:%1]
27 8503 aaronmk
# translate
28 8022 aaronmk
RewriteCond %{HTTP_HOST} !=vegbiendev.nceas.ucsb.edu
29
RewriteCond %{HTTP_HOST} ^(.*)\.([^.]*\.[^.]*)$
30 8507 aaronmk
RewriteRule ^.*$ %{REQUEST_SCHEME}://%2/${subdomain2path:%1}%{ENV:REQUEST_URI_no_extra_/} [discardpath,last,noescape,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 8507 aaronmk
RewriteRule ^([^/]*)(.*)$ %0$2 [discardpath,last,noescape,qsappend]
38 8389 aaronmk
	# last: rewrite in the new subdir instead of applying this dir's rules
39 8035 aaronmk
40 8500 aaronmk
# auto-detect dotpath in query string (having a . before any = )
41
# you can prepend . to force a dotpath, or & to force a query param
42 10669 aaronmk
RewriteCond %{QUERY_STRING} ^(?!\.)[^&]+$
43 8500 aaronmk
RewriteCond %0 ^[^=]*(?:\.|$)
44 10670 aaronmk
RewriteRule ^.*$ $0?.%{QUERY_STRING} [discardpath,noescape]
45 8500 aaronmk
46 8505 aaronmk
## parse dotpath in query string
47 10612 aaronmk
# make dotpath replacement start with ./ instead of /
48
RewriteCond %{QUERY_STRING} ^\.
49
RewriteRule ^$ . [discardpath,noescape,qsappend]
50 8505 aaronmk
# parse dotpath levels repeatedly in QUERY_STRING
51
RewriteCond %{QUERY_STRING} ^\.([^./&]*?)(?:\[([^\[\]/&]*)\])?([.&].*)?$
52
RewriteRule ^(.*?)(?:/(?:index(?:\.\w+)?)?)?$ $1/%1%2?%3 [discardpath,noescape,next,env=needs_redirect:1]
53
# redirect so REQUEST_URI is populated from REQUEST_FILENAME
54
RewriteCond %{ENV:needs_redirect} !=""
55 10611 aaronmk
RewriteRule ^ - [discardpath,last,noescape,qsappend,redirect]
56
	# - uses REQUEST_FILENAME as redirect dest instead of empty REQUEST_URI
57 7997 aaronmk
58 9612 aaronmk
# <dir>/all forces mod_autoindex listing
59
RewriteRule ^(.*/)?all$ $1 [discardpath,last,noescape,qsappend,env=mod_autoindex_listing:1]
60
61
# for dirs, redirect to index.* unless mod_autoindex listing was requested
62 13304 aaronmk
# can't use just "index" because MultiViews doesn't work in Ubuntu 14.04
63
RewriteCond %{REQUEST_FILENAME}index.php -F
64 9612 aaronmk
	# use -F subrequest so that MultiViews auto-appends any extension
65
RewriteCond %{ENV:REDIRECT_mod_autoindex_listing} =""
66 13304 aaronmk
RewriteRule ^(.*/)?$ $1index.php [discardpath,last,noescape,qsappend]
67
RewriteCond %{REQUEST_FILENAME}index.htm -F
68
	# use -F subrequest so that MultiViews auto-appends any extension
69
RewriteCond %{ENV:REDIRECT_mod_autoindex_listing} =""
70
RewriteRule ^(.*/)?$ $1index.htm [discardpath,last,noescape,qsappend]
71 9612 aaronmk
72 8481 aaronmk
# don't rewrite existing dirs with trailing /
73
RewriteCond %{REQUEST_FILENAME} -d
74 8507 aaronmk
RewriteRule ^.+/$ - [discardpath,last,noescape,qsappend]
75 8481 aaronmk
76
# don't rewrite existing files
77 8363 aaronmk
RewriteCond %{REQUEST_FILENAME} -f
78 8507 aaronmk
RewriteRule ^.+$ - [discardpath,last,noescape,qsappend]
79 8041 aaronmk
80 8483 aaronmk
# auto-add trailing / unless has an .htaccess with possible redirect
81
RewriteCond %{REQUEST_FILENAME} -d
82
RewriteCond %{REQUEST_FILENAME}/.htaccess !-f
83 8507 aaronmk
RewriteRule ^.+$ %{REQUEST_URI}/ [discardpath,last,noescape,qsappend,redirect]
84 8482 aaronmk
85 8496 aaronmk
# prepend dir name if it's part of the filename (e.g. dir/file -> dir/dir.file)
86
# works only if dir supports relative redirects and sets %{ENV:innermost_dir}
87
RewriteCond %{REQUEST_FILENAME} ^(.*/)?(.+?)$
88 8498 aaronmk
RewriteCond %1%{ENV:innermost_dir}.%2 -F
89 8507 aaronmk
RewriteRule ^(?!/)(.*/)?(.+?)$ $1%{ENV:innermost_dir}.$2 [discardpath,last,noescape,qsappend,redirect]
90 8496 aaronmk
91 8041 aaronmk
## specific to /
92
93 8443 aaronmk
RewriteCond %{ENV:innermost_dir} =/
94 8507 aaronmk
RewriteRule ^.+$ /VegCore/$0 [discardpath,last,noescape,qsappend]
95 9604 aaronmk
96
97
#### directory indexing
98
99
### mod_autoindex
100
101 11034 aaronmk
IndexOptions +FoldersFirst +HTMLTable +IconsAreLinks +IgnoreCase +TrackModified +VersionSort +XHTML
102 9609 aaronmk
IndexOrderDefault Ascending Description
103 9608 aaronmk
104 11039 aaronmk
IndexStyleSheet /main.css
105
IndexHeadInsert '<div><i>Note that some listed files are not web-accessible. They will produce a "Forbidden" error when clicked.</i></div>'
106 11649 aaronmk
107
IndexIgnoreReset on
108
IndexIgnore .svn