怎么配置Apache服务器禁止所有非法域名访问自己的服务器
发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,本篇内容介绍了"怎么配置Apache服务器禁止所有非法域名访问自己的服务器"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细
千家信息网最后更新 2026年11月01日怎么配置Apache服务器禁止所有非法域名访问自己的服务器
本篇内容介绍了"怎么配置Apache服务器禁止所有非法域名访问自己的服务器"的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
1、http2.4.1以前:
第一种 直接拒绝访问
打开 httpd.conf 文件,将一下配置追加到文件最后。
#直接拒绝所有非法域名ServerName * ServerAlias * Order Allow,Deny Deny from all ErrorLog "/alidata/log/httpd/error.log" CustomLog "/alidata/log/httpd/info.log" common #允许的域名DocumentRoot /alidata/www ServerName www.你的域名 ServerAlias www.你的域名 Options Indexes FollowSymLinks AllowOverride all Order allow,deny Allow from all RewriteEngine On RewriteRule ^(.*)-htm-(.*)$ .php? RewriteRule ^(.*)/simple/([a-z0-9\_]+\.html)$ /simple/index.php? ErrorLog "/alidata/log/httpd/error.log" CustomLog "/alidata/log/httpd/info.log" common重启apache服务:service httpd restart
第二种 跳转到指定目录或文件
打开 httpd.conf 文件,将一下配置追加到文件最后。
#所有非法域名跳转到指定目录或文件#指定目录或文件 DocumentRoot "/yun/www" ServerName * ServerAlias * #允许的域名DocumentRoot /alidata/www/fdt ServerName www.fdt-art.com ServerAlias www.fdt-art.com Options Indexes FollowSymLinks AllowOverride all Order allow,deny Allow from all RewriteEngine On RewriteRule ^(.*)-htm-(.*)$ .php? RewriteRule ^(.*)/simple/([a-z0-9\_]+\.html)$ /simple/index.php? #错误日志 ErrorLog "/alidata/log/httpd/error.log" CustomLog "/alidata/log/httpd/info.log" common重启apache服务:service httpd restart
2、http2.4.1 以后:
http2.4.1 以后不再需要NameVirtualHost以及不再支持ServerName * 这种写法。
使用ServerName * 会报Invalid ServerName "*" use ServerAlias to set multiple server names.
第一种:直接拒绝
打开 httpd.conf 在文件末尾加上一下代码:
#禁止所有非法域名ServerName 服务器ip ServerAlias * Order Allow,Deny Deny from all #允许访问的域名DocumentRoot /alidata/www ServerName www.你的域名 ServerAlias www.你的域名 Options Indexes FollowSymLinks AllowOverride all Order allow,deny Allow from all RewriteEngine On RewriteRule ^(.*)-htm-(.*)$ .php? RewriteRule ^(.*)/simple/([a-z0-9\_]+\.html)$ /simple/index.php? #错误日志保存位置 ErrorLog "/alidata/log/httpd/error.log" CustomLog "/alidata/log/httpd/info.log" common重启apache服务:service httpd restart
第二种:跳转到指定目录或文件
打开 httpd.conf 在文件末尾加上一下代码:
#禁止所有非法域名DocumentRoot "/alidata/www" ServerName 服务器ip ServerAlias * Order Allow,Deny Allow from all #允许访问的域名DocumentRoot /alidata/www/fdt ServerName www.fdt-art.com ServerAlias www.fdt-art.com Options Indexes FollowSymLinks AllowOverride all Order allow,deny Allow from all RewriteEngine On RewriteRule ^(.*)-htm-(.*)$ .php? RewriteRule ^(.*)/simple/([a-z0-9\_]+\.html)$ /simple/index.php? #错误日志保存位置 ErrorLog "/alidata/log/httpd/error.log" CustomLog "/alidata/log/httpd/info.log" common重启apache服务:service httpd restart
"怎么配置Apache服务器禁止所有非法域名访问自己的服务器"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注网站,小编将为大家输出更多高质量的实用文章!
域名
服务
文件
服务器
配置
目录
日志
错误
代码
位置
内容
更多
末尾
知识
实用
学有所成
接下来
写法
困境
实际
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
互联网最新的科技
科技信息互联网
科技与互联网发展
万易互联网科技有限公司
互联网科技视频
奇酷互联网络科技公司
菲比寻常互联网科技
互联网科技生活的内容
互联网巨头投资的硬核科技
深圳国际航运科技和互联网
阿里巴巴算科技企业还是互联网
阿里互联网科技公司
南山科技园互联网公司有哪些
佳云科技和互联网广告
互联网还是高科技吗
武汉健翔互联网络科技有限公司
下一代互联网重大应用科技园
互联网硬科技公司
上海万顺科技互联网有限公司招聘
马化腾互联网科技教学
瑰夏咖啡
北京路客互联网科技有限公司
科技与互联网
科技互联网技术
互联网金融与金融科技
美国互联网科技
华中科技大学互联网的牛人
江苏互联网智能科技软件
云南互联网科技学费
数字互联网科技有限公司