Disable HTTP Methods in Apache

Solution 1:

It really seems that defining the error code is a bit harder than it should be.

However, one workaround MIGHT be using the mod_rewrite. Popped that one out of my head due the fact that in at least 99% of impossible-looking Apache problems mod_rewrite can provide its voodoo dance and solve your problem.

If everything else fails, try something like

RewriteEngine On
RewriteCond %{REQUEST_METHOD} !^GET [AND]
RewriteCond %{REQUEST_METHOD} !^POST 
RewriteRule .* /yourerrordocuments/405.html [R=405,L] 

I know that is probably not the nicest solution around, but it should kind of work...

Solution 2:

For trace method you can add this

TraceEnable off

in your main configuration file

Solution 3:

To enable the rewrite engine, add the following:

 RewriteEngine On 

Please note that by default, rewrite configurations are not inherited across virtual servers. Add RewriteEngine On to each virtual host.

RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS)
RewriteRule .* - [F]