WP-Mix

A fresh mix of code snippets and tutorials

Apache Require HTTP 1.1 for POST Requests

A reader recently asked how to limit POST requests to only HTTP 1.1. Well here is an .htaccess snippet that will do it.

# REQUIRE HTTP 1.1 POST
<IfModule mod_rewrite.c>
	RewriteCond %{THE_REQUEST} !^POST\ HTTP/1\.1$ [NC]
	RewriteRule .* - [F,L]
</IfModule>

No modifications are required; simply add to your site’s root .htaccess file, save changes and done.

Note where the code says 1\.1. You can change that to allow only HTTP 1.0 or any other HTTP version. Just change it like 1\.0. (The backslash escapes the period to match literally, instead of wildcard.)

Learn more

.htaccess made easy