Bug 18669 - RewriteCond affecting wrong rule in koha-httpd.conf
[koha.git] / etc / koha-httpd.conf
1 # Koha Apache Configuration Directives
2
3 #NameVirtualHost *
4
5 ## OPAC
6 <VirtualHost __WEBSERVER_IP__:__WEBSERVER_PORT__>
7    ServerAdmin  __WEBMASTER_EMAIL__
8    DocumentRoot __OPAC_WWW_DIR__
9    ServerName __WEBSERVER_HOST__
10 #  ServerAlias opac.mydomain.com
11    ScriptAlias /cgi-bin/koha/ "__OPAC_CGI_DIR__/opac/"
12    ScriptAlias /index.html "__OPAC_CGI_DIR__/opac/opac-main.pl"
13    ScriptAlias /opac-search.pl "__OPAC_CGI_DIR__/opac/opac-search.pl"
14    ScriptAlias /search "__OPAC_CGI_DIR__/opac/opac-search.pl"
15    ErrorLog __LOG_DIR__/koha-opac-error_log
16 #  CustomLog __LOG_DIR__/koha-opac-access.log combined
17 #  TransferLog __LOG_DIR__/koha-opac-access.log
18    SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml"
19    SetEnv PERL5LIB "__PERL_MODULE_DIR__"
20    SetEnv MEMCACHED_SERVERS "__MEMCACHED_SERVERS__"
21    SetEnv MEMCACHED_NAMESPACE "__MEMCACHED_NAMESPACE__"
22
23    # This syntax allows you to override a system preference
24    # for a given virtual host. Use with caution!
25    # You should add all the system preferences you override
26    # in one or more vhosts to the environment variable
27    # OVERRIDE_SYSPREF_NAMES for your staff intranet vhost
28    # SetEnv OVERRIDE_SYSPREF_PrefName Value
29
30    <Directory "__OPAC_WWW_DIR__">
31       Options -Indexes
32    </Directory>
33
34    # Secure internal stuff
35    <DirectoryMatch "__OPAC_WWW_DIR__/.*/(modules|xslt|includes)">
36       Order deny,allow
37       Deny from all
38    </DirectoryMatch>
39
40    <IfModule mod_gzip.c>
41      mod_gzip_on yes
42      mod_gzip_dechunk yes
43      mod_gzip_keep_workfiles No
44      mod_gzip_can_negotiate yes
45      mod_gzip_update_static No
46      mod_gzip_temp_dir /tmp
47      mod_gzip_minimum_file_size 512
48      mod_gzip_maximum_file_size 1000000
49      mod_gzip_maximum_inmem_size 1000000
50      mod_gzip_handle_methods GET POST
51      mod_gzip_item_exclude reqheader "User-Agent: .*Mozilla/4\..*\["
52      mod_gzip_item_exclude mime ^image/.*
53      mod_gzip_item_exclude rspheader Content-Type:image/*
54      mod_gzip_item_include file \.js$
55      mod_gzip_item_include mime ^application/javascript$
56      mod_gzip_item_include mime ^application/x-javascript$
57      mod_gzip_item_include file \.php$
58      mod_gzip_item_include mime ^text/html$
59      mod_gzip_item_include file \.css$
60      mod_gzip_item_include mime ^text/css$
61   </IfModule>
62
63   <IfModule mod_deflate.c>
64
65     # Compress content with type html, text, and css, ...
66     AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css
67     AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
68
69     DeflateCompressionLevel 9
70
71     # Properly handle old browsers that do not support compression
72     BrowserMatch ^Mozilla/4 gzip-only-text/html
73     BrowserMatch ^Mozilla/4\.0[678] no-gzip
74     BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
75
76     DeflateFilterNote Input instream
77     DeflateFilterNote Output outstream
78     DeflateFilterNote Ratio ratio
79
80     LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
81     <IfModule mod_headers.c>
82        #properly handle requests coming from behind proxies
83        Header append Vary User-Agent
84     </IfModule>
85   </IfModule>
86
87
88 #  Repeat this virtualhost stanza changing the following environment vars to
89 #  create multiple OPAC interfaces with custom css and/or search limits:
90 #  SetEnv OPAC_CSS_OVERRIDE mystyle.css
91 #  SetEnv OPAC_SEARCH_LIMIT branch:CODE
92 #  SetEnv OPAC_LIMIT_OVERRIDE 1
93
94    Options +FollowSymLinks
95
96    ErrorDocument 400 /cgi-bin/koha/errors/400.pl
97    ErrorDocument 401 /cgi-bin/koha/errors/401.pl
98    ErrorDocument 403 /cgi-bin/koha/errors/403.pl
99    ErrorDocument 404 /cgi-bin/koha/errors/404.pl
100    ErrorDocument 500 /cgi-bin/koha/errors/500.pl
101
102    <IfModule mod_rewrite.c>
103      # Rewrite Rules
104      RewriteEngine On
105
106      # Uncomment to turn on rewrite logging
107      #RewriteLog __LOG_DIR__/koha-opac-rewrite.log
108      #RewriteLogLevel 1
109
110      #The following two directives are unnecessary to proper Koha functioning.
111      #RewriteCond %{QUERY_STRING} (.*?)(?:[A-Za-z0-9_-]+)=&(.*)
112      #RewriteRule (.+) $1?%1%2 [N,R,NE]
113      RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/opac-detail\.pl?bib=$1 [PT]
114      RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT]
115      RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT]
116
117      # REST API configuration
118      Alias "/api" "__API_CGI_DIR__"
119      <Directory __API_CGI_DIR__>
120        Options +ExecCGI +FollowSymlinks
121        AddHandler cgi-script .pl
122
123        SetEnv MOJO_MODE "production"
124
125        RewriteEngine On
126        RewriteBase /api/
127        RewriteCond %{REQUEST_FILENAME} !-f
128        RewriteCond %{REQUEST_FILENAME} !-d
129        RewriteCond %{DOCUMENT_ROOT}/../api/$1/app.pl -f
130        RewriteRule ^(.*?)/.* $1/app.pl/api/$0 [L]
131      </Directory>
132    </IfModule>
133 </VirtualHost>
134
135 ## Intranet
136 <VirtualHost __WEBSERVER_IP__:__WEBSERVER_PORT_LIBRARIAN__>
137    ServerAdmin __WEBMASTER_EMAIL__
138    DocumentRoot __INTRANET_WWW_DIR__
139    ServerName __WEBSERVER_HOST__:__WEBSERVER_PORT_LIBRARIAN__
140 #  ServerAlias intranet.mydomain.com
141    ScriptAlias /cgi-bin/koha/ "__INTRANET_CGI_DIR__/"
142    ScriptAlias /index.html "__INTRANET_CGI_DIR__/mainpage.pl"
143    ScriptAlias /search "__INTRANET_CGI_DIR__/catalogue/search.pl"
144    Alias /plugin/ "__PLUGINS_DIR__/"
145    ErrorLog __LOG_DIR__/koha-error_log
146 #  TransferLog __LOG_DIR__/koha-access.log
147    SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml"
148    SetEnv PERL5LIB "__PERL_MODULE_DIR__"
149    SetEnv MEMCACHED_SERVERS "__MEMCACHED_SERVERS__"
150    SetEnv MEMCACHED_NAMESPACE "__MEMCACHED_NAMESPACE__"
151    Options +FollowSymLinks
152
153    # If you are overriding any system preferences,
154    # list them in this variable so the preference editor
155    # knows that they have been overridden.
156    # SetEnv OVERRIDE_SYSPREF_NAMES "Pref1,Pref2,Pref3"
157
158    ErrorDocument 400 /cgi-bin/koha/errors/400.pl
159    ErrorDocument 401 /cgi-bin/koha/errors/401.pl
160    ErrorDocument 403 /cgi-bin/koha/errors/403.pl
161    ErrorDocument 404 /cgi-bin/koha/errors/404.pl
162    ErrorDocument 500 /cgi-bin/koha/errors/500.pl
163
164    <Directory "__INTRANET_WWW_DIR__">
165       Options -Indexes
166    </Directory>
167
168    # Secure internal stuff
169    <DirectoryMatch "__INTRANET_WWW_DIR__/.*/(modules|xslt|includes)">
170       Order deny,allow
171       Deny from all
172    </DirectoryMatch>
173
174    <IfModule mod_gzip.c>
175      mod_gzip_on yes
176      mod_gzip_dechunk yes
177      mod_gzip_keep_workfiles No
178      mod_gzip_can_negotiate yes
179      mod_gzip_update_static No
180      mod_gzip_temp_dir /tmp
181      mod_gzip_minimum_file_size 512
182      mod_gzip_maximum_file_size 1000000
183      mod_gzip_maximum_inmem_size 1000000
184      mod_gzip_handle_methods GET POST
185      mod_gzip_item_exclude reqheader "User-Agent: .*Mozilla/4\..*\["
186      mod_gzip_item_exclude mime ^image/.*
187      mod_gzip_item_exclude rspheader Content-Type:image/*
188      mod_gzip_item_include file \.js$
189      mod_gzip_item_include mime ^application/javascript$
190      mod_gzip_item_include mime ^application/x-javascript$
191      mod_gzip_item_include file \.php$
192      mod_gzip_item_include mime ^text/html$
193      mod_gzip_item_include file \.css$
194      mod_gzip_item_include mime ^text/css$
195    </IfModule>
196
197    <IfModule mod_deflate.c>
198
199      # Compress content with type html, text, and css, ...
200      AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css
201      AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml application/javascript application/x-javascript
202
203      DeflateCompressionLevel 9
204
205      # Properly handle old browsers that do not support compression
206      BrowserMatch ^Mozilla/4 gzip-only-text/html
207      BrowserMatch ^Mozilla/4\.0[678] no-gzip
208      BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
209
210      DeflateFilterNote Input instream
211      DeflateFilterNote Output outstream
212      DeflateFilterNote Ratio ratio
213
214      LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
215      <IfModule mod_headers.c>
216        #properly handle requests coming from behind proxies
217        Header append Vary User-Agent
218      </IfModule>
219   </IfModule>
220
221    <IfModule mod_rewrite.c>
222      # Rewrite Rules
223      RewriteEngine On
224
225      # Uncomment to turn on rewrite logging
226      #RewriteLog __LOG_DIR__/koha-intranet-rewrite.log
227      #RewriteLogLevel 1
228
229      #The following two directives are unnecessary to proper Koha functioning.
230      #RewriteCond %{QUERY_STRING} (.*?)(?:[A-Za-z0-9_-]+)=&(.*)
231      #RewriteRule (.+) $1?%1%2 [N,R,NE]
232      RewriteRule ^/bib/([^\/]*)/?$ /cgi-bin/koha/detail\.pl?bib=$1 [PT]
233      RewriteRule ^/isbn/([^\/]*)/?$ /search?q=isbn:$1 [PT]
234      RewriteRule ^/issn/([^\/]*)/?$ /search?q=issn:$1 [PT]
235
236
237      # REST API configuration
238      Alias "/api" "__API_CGI_DIR__"
239      <Directory __API_CGI_DIR__>
240        Options +ExecCGI +FollowSymlinks
241        AddHandler cgi-script .pl
242
243        SetEnv MOJO_MODE "production"
244
245        RewriteEngine On
246        RewriteBase /api/
247        RewriteCond %{REQUEST_FILENAME} !-f
248        RewriteCond %{REQUEST_FILENAME} !-d
249        RewriteCond %{DOCUMENT_ROOT}/../api/$1/app.pl -f
250        RewriteRule ^(.*?)/.* $1/app.pl/api/$0 [L]
251      </Directory>
252    </IfModule>
253 </VirtualHost>
254
255 # Uncomment this VirtualHost to enable API access through
256 # api.__WEBSERVER_HOST__:__WEBSERVER_PORT__
257 #<VirtualHost __WEBSERVER_IP__:__WEBSERVER_PORT__>
258 #  ServerAdmin __WEBMASTER_EMAIL__
259 #  DocumentRoot __INTRANET_CGI_DIR__/api
260 #  ServerName api.__WEBSERVER_HOST__:__WEBSERVER_PORT__
261 #  SetEnv KOHA_CONF "__KOHA_CONF_DIR__/koha-conf.xml"
262 #  SetEnv PERL5LIB "__PERL_MODULE_DIR__"
263 #  ErrorLog __LOG_DIR__/koha-api-error_log
264 #
265 #  <IfModule mod_rewrite.c>
266 #    <Directory __API_CGI_DIR__>
267 #      Options +ExecCGI +FollowSymlinks
268 #      AddHandler cgi-script .pl
269 #
270 #      SetEnv MOJO_MODE "production"
271 #
272 #      RewriteEngine on
273 #
274 #      RewriteRule ^api/(.*) $1 [L]
275 #
276 #      RewriteCond %{REQUEST_FILENAME} !-f
277 #      RewriteCond %{REQUEST_FILENAME} !-d
278 #      RewriteCond %{DOCUMENT_ROOT}/$1/app.pl -f
279 #      RewriteRule ^(.*?)/.* $1/app.pl/api/$0 [L]
280 #    </Directory>
281 #  </IfModule>
282 #</VirtualHost>