Mobile app version of vmapp.org
Login or Join
Angie530

: 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.

@Angie530

Posted in: #Apache2 #IpAddress #ModSecurity

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?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Angie530

2 Comments

Sorted by latest first Latest Oldest Best

 

@Pope3001725

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.

10% popularity Vote Up Vote Down


 

@Nimeshi995

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme