【问题标题】:htaccess - load index.html from subdirectoryhtaccess - 从子目录加载 index.html
【发布时间】:2018-03-02 12:25:12
【问题描述】:

我的 htdocs 文件夹的子目录中有一个 index.html 文件。类似的东西:

example.com/htdocs/web/index.html

现在我希望它在我调用example.com 时自动加载,但我不想将index.html 文件移动到根目录。有没有办法用 .htacess 文件解决这个问题?

类似:

"如果 example.com 是请求,则从 example.com/web/index.html 加载内容"

我没有对 .htaccess 文件进行太多工作,也找不到解决我问题的方法。

【问题讨论】:

    标签: html .htaccess


    【解决方案1】:

    您可以为此使用the AliasMatch directive。例如:

    AliasMatch "^/$" "/var/www/htdocs/web/index.html"
    

    【讨论】:

    • 我试过了,但我只得到了 500 的回报 --> AliasMatch "^/$" "/var/www/example.com/htdocs/web/index.html"
    • @dwdawdawdaw — 500 仅表示“出了点问题”。您需要阅读您的错误日志以了解具体内容。
    【解决方案2】:

    试试这个 .htaccess 配置

    <IfModule mod_rewrite.c>
       RewriteEngine On 
       RewriteRule ^(.*)$ /var/www/htdocs/web/$1 [L]
    </IfModule>
    

    【讨论】:

      猜你喜欢
      • 2014-09-19
      • 2015-03-09
      • 2016-05-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-07-06
      相关资源
      最近更新 更多