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