no comments yet
14 Apr 2018

htaccess禁止通过ip直接访问网站

通过IP直接访问的话会301跳转到相应域名,.htaccess内容:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{http_host} ^101.100.102.90 [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
RewriteBase /
</IfModule>