: Prevent request via IP address of server I'm pretty sure there's a way to prevent access to a website through the server IP address and to force the user to enter the domain name instead.
I'm pretty sure there's a way to prevent access to a website through the server IP address and to force the user to enter the domain name instead.
so that 156.56.75.87 should trigger a 403 and only access through www.example.com should be authorized.
I think there was a modsecurity rule for that but I can't find it anywhere. Does someone know?
More posts by @Angie530
2 Comments
Sorted by latest first Latest Oldest Best
The rule to activate this block rule in mod_security can be found in:
base_rules/modsecurity_crs_21_protocol_anomalies.conf
That will block access to the website when accessed through the server IP-address.
Here is an .htaccess option for you:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^10.0.11.101$ [NC]
RewriteRule ^(.*)$ www.example.com/ [R,L]
...to redirect and...
RewriteEngine On
RewriteCond %{HTTP_HOST} ^10.0.11.101$ [NC]
RewriteRule .* - [F,L]
...to block.
Obviously, you will need to change the IP address and domain name to suit your needs. This should redirect any IP based reference to the domain name.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.