Apache: How to redirect OPTIONS request with .htaccess?
Posted
by Milan Babuškov
on Server Fault
See other posts from Server Fault
or by Milan Babuškov
Published on 2010-05-15T23:50:57Z
Indexed on
2010/05/16
0:01 UTC
Read the original article
Hit count: 376
I have Apache 2.2.4 server with a lot of messages like this in the access_log:
::1 - - [15/May/2010:19:55:01 +0200] "OPTIONS * HTTP/1.0" 400 543
::1 - - [15/May/2010:20:22:17 +0200] "OPTIONS * HTTP/1.0" 400 543
::1 - - [15/May/2010:20:24:58 +0200] "OPTIONS * HTTP/1.0" 400 543
::1 - - [15/May/2010:20:25:55 +0200] "OPTIONS * HTTP/1.0" 400 543
::1 - - [15/May/2010:20:27:14 +0200] "OPTIONS * HTTP/1.0" 400 543
These are the "internal dummy connections" as explained on this page:
http://wiki.apache.org/httpd/InternalDummyConnection
The page also hits my main problem: "In 2.2.6 and earlier, in certain configurations, these requests may hit a heavy-weight dynamic web page and cause unnecessary load on the server. You can avoid this by using mod_rewrite to respond with a redirect when accessed with that specific User-Agent or IP address."
Well, obviously I cannot use UserAgent because I minimized the server signature, but I could use IP address. However, I don't have a clue what should the RewriteCond and RewriteRule look for IPv6 address ::1.
The website where this runs is using CodeIgniter, so there is already the following .htaccess in place, I just need to add to it:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ /index.php?/$1 [G]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
Any idea how to write this .htaccess rule?
© Server Fault or respective owner