In our web site can actually be accessed via IP directly, of course, in our testing is convenient, but once in the actual production server so allow IP direct access to the source site is a dangerous move, if your production server is malicious binding, traffic hijacked to another domain name, Will be banned by the Ad alliance. Because your domain name can be accessed through the IP, if the malicious use of domain name resolution to your IP, your site can be accessed through someone else's domain name, time a long ad alliance found that domain name and IP does not meet the blocked, and so others to bind your IP to other malicious domain name is also very dangerous. So we can use Apache rewrite and PHP implementation 403 error To disable the direct use of IP access to your site
Set up a host configuration on your virtual host to access rewrite custom PHP pages from IP
<virtualhost *:80> documentroot "/data/www/error" #自定义的php页面目录 ServerName XX. Xx. Xx. xx# IP available on the server <Directory/data/www/error> allowoverride all Rewriteengine on# This must be open Orde R Allow,deny allow from all </Directory></VirtualHost>
Then we build a simple PHP file in the/data/www/error directory, using 403.php
[[email protected] ERROR] #vim 403.php<?phpheader ("http/1.1 403 Bad Request"); ?>
And then we'll restart Apache.
This article from the "Technical essay" blog, reproduced please contact the author!
Disable server IP access for Web sites under the Apache environment