Recently in the forum to see someone asked how Linux set only allow domain name access to the site and prohibit IP access to the site, before they have used this function, you can prevent others to use IP address to visit their own site, below I have my own environment to give a solution, I use Oneinstack A key package, LANMP environment, in fact, are not too much, similar, as long as the understanding of the principle, the following is good to run.
The specific method is: To find the Apache configuration file, my environment path is:/usr/local/apache/conf/httpd.conf, at the bottom of the file, include conf/vhost/*.conf this sentence before adding the following code:
<VirtualHost*:88># [email protected] for admin mailbox ServerAdmin [email protected] # Default binding path DocumentRoot "/home/wwwroot/default" # IP Address ServerName 115.28.152.187<Directory"/home/wwwroot/default">setoutputfilter DEFLATE Options followsymlinks Require all granted allowoverride None Order Allow,deny allow from all DirectoryIndex index.php index.htm</Directory> <Ifmodulemod_rewrite.c>rewriteengine on Rewritecond%{query_string} ^ (. *) $ rewriterule ^ (. *) $ http:\/\/www\.bbseat\.com \.cn\/[R=301,l]</Ifmodule></VirtualHost>
The above code is to the IP address to access the request all jump to the site you set, of course, you can also directly prohibit access, but feel this is more than the direct abruptly of the forbidden access more friendly.
How Linux is set to allow only domain names to access sites and disable IP access to sites