1、如果对应的ip或者域名没有配置虚拟主机,会默认访问第一个配置,第一个虚拟主机配置通常是在000-default.conf中,
cd /etc/apache2/sites-available
2、编辑 000-default.conf
vim 000-default.conf
3、在DocumentRoot /var/www/html下面增加
RewriteEngine On RewriteCond %{HTTP_HOST} !^(www\.)?你的域名\.com$ [NC] RewriteRule ^ - [F]
Ubuntu中 禁止Apache2可以通过IP直接访问
| Title | Ubuntu中 禁止Apache2可以通过IP直接访问 |
|---|---|
| Framework | Ubuntu |
| User | wy8817399@vip.qq.com |
| Id | 4 |
| Created | 1/6/26, 1:46 PM |
| Modified | 1/22/26, 10:47 AM |
| Published | Yes |
Content