【问题标题】:.htaccess If file exists, set document root to subdirectory.htaccess 如果文件存在,则将文档根目录设置为子目录
【发布时间】:2016-11-19 04:37:30
【问题描述】:

我想使用 .htaccess 设置一个规则,如果 config.php 存在则将根目录设置为 /,如果 config.php 不存在,则将根目录设置为 /install。

如何做到这一点?

谢谢!

【问题讨论】:

    标签: apache .htaccess redirect document-root apache-modules


    【解决方案1】:
    RewriteEngine on
    RewriteCond %{DOCUMENT_ROOT}/config.php !-f
    RewriteRule ^/?$ /install [L]
    

    如果 /config.php 在您的文件系统中不存在,这会将 /install 设置为您的主目录。

    【讨论】:

      猜你喜欢
      • 2014-10-24
      • 2013-05-06
      • 2021-12-19
      • 1970-01-01
      • 2012-03-13
      • 2015-11-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多