There can be a case when you want to restrict any request methods for your website. Restrict in the sense you don’t want user to perform that action. Different Request methods available are as below:
So now we all know that most used Request Methods are GET and POST and in your application you needs only these two methods available in that case you can disable rest of the Request Methods just by placing a single line of code in .htaccess file.
After placing below code in htaccess file, user will get Forbidden Error when user has initiated a restricted Request Methods.
Now let’s see how to achieve this.
RewriteRule .* - [F]
So after placing this code your application will show forbidden error for the TRACE, TRACK, OPTIONS and HEAD Request Methods.
Hope you enjoyed this small trick for your website. Subscribe to our RSS Feed via Email for more Htaccess Tricks.