Configure Apache server to prohibit all illegal domain names from accessing their servers

Source: Internet
Author: User

1, HTTP2.4. 1 before: The first direct deny access to open the httpd.conf file, append the configuration to the file at the end. <pre name="Code" class="HTML"><pre name="Code" class="HTML"><pre name="Code" class="HTML">#直接拒绝所有非法域名<virtualhost *: the>ServerName*Serveralias* <location/>Order Allow,deny Deny from All</Location>errorlog"/alidata/log/httpd/error.log"Customlog"/alidata/log/httpd/info.log"Common</virtualhost></pre><pre name="Code" class="HTML"><pre name="Code" class="HTML">#允许的域名<virtualhost *: the>DocumentRoot/alidata/www ServerName www. your domain name Serveralias www. your domain name<directory"/alidata/www">Options Indexes followsymlinks allowoverride all Order allow,deny allow from All</Directory> <ifmodule mod_rewrite.c>Rewriteengine on Rewriterule^ (. *)-htm-(. *) $. php?Rewriterule^ (. *)/simple/([a-z0-9\_]+\.html) $/simple/index.php? </IfModule>errorlog"/alidata/log/httpd/error.log"Customlog"/alidata/log/httpd/info.log"Common</VirtualHost>Restart Apache Service: Service httpd Restart the second jump to the specified directory or file to open the httpd.conf file, append the configuration to the file at the end. #所有非法域名跳转到指定目录或文件<pre name="Code" class="HTML"><pre name="Code" class="HTML"><virtualhost *: the>#指定目录或文件 DocumentRoot"/yun/www"ServerName*Serveralias*</virtualhost></pre><pre name="Code" class="HTML"><pre name="Code" class="HTML">#允许的域名<virtualhost *: the>DocumentRoot/alidata/www/FDT ServerName WWW.FDT-art.com Serveralias WWW.FDT-art.com<directory"/ALIDATA/WWW/FDT">Options Indexes followsymlinks allowoverride all Order allow,deny allow from All</Directory> <ifmodule mod_rewrite.c>Rewriteengine on Rewriterule^ (. *)-htm-(. *) $. php?Rewriterule^ (. *)/simple/([a-z0-9\_]+\.html) $/simple/index.php? </IfModule>#错误日志 errorlog"/alidata/log/httpd/error.log"Customlog"/alidata/log/httpd/info.log"Common</VirtualHost>Restart Apache Services: Service httpd restart2, HTTP2.4.1later: HTTP2.4.1No longer need namevirtualhost and no longer support servername *this notation. Using servername* will be reported invalid ServerName "*" Use Serveralias toSetmultiple server names. First: Direct deny open httpd.conf add the code at the end of the file:<pre name="Code" class="HTML"><pre name="Code" class="HTML">#禁止所有非法域名<virtualhost *: the>ServerName server IP serveralias* <location/>Order Allow,deny Deny from All</location></virtualhost><pre name="Code" class="HTML">#允许访问的域名<virtualhost *: the>DocumentRoot/alidata/www ServerName www. your domain name Serveralias www. your domain name<directory"/alidata/www">Options Indexes followsymlinks allowoverride all Order allow,deny allow from All</Directory> <ifmodule mod_rewrite.c>Rewriteengine on Rewriterule^ (. *)-htm-(. *) $. php?Rewriterule^ (. *)/simple/([a-z0-9\_]+\.html) $/simple/index.php? </IfModule>#错误日志保存位置 errorlog"/alidata/log/httpd/error.log"Customlog"/alidata/log/httpd/info.log"Common</VirtualHost>Restart Apache Service: Service httpd Restart Second: Jump to the specified directory or file open httpd.conf Add the code at the end of the file:<pre name="Code" class="HTML"><pre name="Code" class="HTML">#禁止所有非法域名<virtualhost *: the>DocumentRoot"/alidata/www"ServerName server IP serveralias* <Location/alidata/www>Order Allow,deny allow from All</location></virtualhost></pre><pre name="Code" class="HTML">#允许访问的域名<virtualhost *: the>DocumentRoot/alidata/www/FDT ServerName WWW.FDT-art.com Serveralias WWW.FDT-art.com<directory"/ALIDATA/WWW/FDT">Options Indexes followsymlinks allowoverride all Order allow,deny allow from All</Directory> <ifmodule mod_rewrite.c>Rewriteengine on Rewriterule^ (. *)-htm-(. *) $. php?Rewriterule^ (. *)/simple/([a-z0-9\_]+\.html) $/simple/index.php? </IfModule>#错误日志保存位置 errorlog"/alidata/log/httpd/error.log"Customlog"/alidata/log/httpd/info.log"Common</VirtualHost>Restart Apache Services: Service httpd restart

Configure Apache server to prohibit all illegal domain names from accessing their servers

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.