Apache NameVirtualHost中IP到域名的Rewrite

有台apache服务器,想把所有通过IP的http访问重定向到域名http://dev.ymeng.net,结果完全没效果,VirtualHost配置如下

<virtualhost *:80>
    DocumentRoot /var/www/html/dev.ymeng.net
    ServerName dev.ymeng.net
    ErrorLog /var/log/apache2/dev.ymeng.net-error_log
 
    <directory "/var/www/html/dev.ymeng.net">
      Order allow,deny
      Deny from all
      Allow from 212.5.5.1
    </directory>
</virtualhost>
 
<virtualhost *:80>
    DocumentRoot /var/www/html/dev.ymeng.net
    ServerName 217.12.15.69
    ErrorLog /var/log/apache2/dev.ymeng.net-error_log
 
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^217\.12\.15\.69
    RewriteRule ^(.*)$ http://dev.ymeng.net [R,L]
 
    <directory "/var/www/html/dev.ymeng.net">
      Order allow,deny
      Deny from all
    </directory>
</virtualhost>

仔细检查后,发现NameVirtualHost被注释掉了
NameVirtualHost *:80