【问题标题】:apache url rewrite not removing the IP address from the urlapache url重写不从url中删除IP地址
【发布时间】:2014-03-28 07:48:42
【问题描述】:

我在我的 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 地址,而是将 ServerName 显示为 site.com

【问题讨论】:

  • 问题是什么?
  • 我假设您希望您的网址是 site.com/directory/index.php。
  • 你能再解释一下吗?
  • 你是如何到达显示“x.x.x.x/directory/index.php”的?

标签: php apache amazon-ec2


【解决方案1】:

当您通过 IP 地址访问时,VirtualHost 不会重写 URL。

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

如果你去IP地址,它会显示IP,如果你去命名域,它会去名字。尝试仅使用名称。

【讨论】:

    猜你喜欢
    • 2013-02-27
    • 1970-01-01
    • 2017-07-02
    • 1970-01-01
    • 2022-03-04
    • 2011-02-06
    • 2020-09-06
    • 1970-01-01
    • 2023-04-03
    相关资源
    最近更新 更多