【问题标题】:Site requires base url to include index.php for it to work网站需要包含 index.php 的基本 url 才能正常工作
【发布时间】:2012-12-07 01:15:30
【问题描述】:

我们正在测试我们使用的 scalr。我们在文件夹/var/www/subdomain.example.com/public_html 中设置了一个站点,其虚拟主机配置如下:

<VirtualHost *:80>
       ServerAlias www.{$host} {$server_alias}
       ServerAdmin {$server_admin}
       DocumentRoot {$document_root}
       ServerName {$host}
       ErrorLog {$logs_dir}/http-{$host}-error.log
       CustomLog {$logs_dir}/http-{$host}-access.log combined
</VirtualHost>

当我们转到subdomain.example.com 时,它会显示主机默认消息,例如“欢迎来到 Scalr” - 但如果我们转到 subdomain.example.com/index.php,该网站正在运行。有没有办法让基本 url 直接指向 index.php 而不显示它?

【问题讨论】:

    标签: php apache ubuntu virtualhost scalr


    【解决方案1】:

    你试过了吗:

    DirectoryIndex index.php
    

    更多资源:http://httpd.apache.org/docs/2.2/mod/mod_dir.html

    在你的情况下:

    <VirtualHost *:80>
      # (other directives)
      DirectoryIndex index.php
    </VirtualHost>
    

    更新

    正如jcjr 建议的那样,该指令也可以放在.htaccess 文件中,但请确保您已通过正确的AllowOverride 指令值启用此类方法:

    http://httpd.apache.org/docs/2.2/mod/core.html

    【讨论】:

    • 可能是最好的方法。使用 .htaccess 文件可能是另一种选择。
    猜你喜欢
    • 2012-06-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-25
    • 2016-12-08
    • 2020-05-04
    • 2015-09-30
    • 2019-03-15
    相关资源
    最近更新 更多