apache url重写没有从url中删除IP地址


apache url rewrite not removing the IP address from the url

我已经在我的AWS EC2 apache中设置了以下虚拟主机。

<VirtualHost 99.999.999.999:80>
  DocumentRoot /var/www/html/mysite
ServerName site.com
 # Other directives here ...
<FilesMatch "'.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=290304000, public"
</FilesMatch>
</VirtualHost>

但是它仍然显示url为99.999.999.999/directory/index.php

我已经遵循了设置,我想知道这里是否有什么我错过了?

我期望的结果是,当我在浏览器中输入www.site.com时,它会转到www.site.com/directory/index.php。当前输入此命令将把我发送到99.999.999.999/directory/index.php.

我的印象是,设置虚拟主机在我已经定义的方式将停止显示ip地址,而不是显示服务器名称为site.com

VirtualHost将不会重写 URL,当你访问它的IP地址。

例如,您可以使用http://www.google.comhttp://74.125.20.105/访问Google

如果你去到IP地址,它会显示IP,如果你去到命名域名,它会转到名称。试着直接使用名字。