Thursday, February 8, 2024

[SOLVED] Disabling HTTP methods and using Force HTTP with mod_rewrite in Apache

Issue

In my virtual host file on Apache, I want to disable HTTP methods and use force https as well. How will the mod_rewrite rules and conditions work? I have following in virtual host file.

RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^(OPTIONS|TRACE)
RewriteRule .* - [F]
RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [L,R]

Solution

Adding the mod-rewrite rule for disabling HTTP options methods in "ssl.conf" file solved the issue.



Answered By - hshantanu
Answer Checked By - Pedro (WPSolving Volunteer)