How Linux is set to allow only domain names to access sites and disable IP access to sites

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.