Disclosure: Hosting Canada is community-supported. We may earn a commission when you make a purchase through one of our links. Learn more.

Preventing the requests containing invalid characters

If you want to deny requests that contain invalid characters, you can do so by using Mod_Rewrite. But stay aware that this may break links with certain site setups.

For enabling this, you need to make an .htaccess file by following the guidance and the main instructions that include the text below.

RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} !^[A-Z]{3,9}\ [a-zA-Z0-9\.\+_/\-\?\=\&]+\ HTTP/ [NC]
RewriteRule .* - [F,NS,L]