【发布时间】:2014-09-13 05:59:05
【问题描述】:
在访问我的 php 脚本之前,用户需要访问 install.php 并配置脚本。 install.php 将在完成后自行删除。删除 install.php 后,用户必须能够访问 index.php
我尝试过的:
RewriteEngine On
RewriteBase /myscript/
RewriteRule ^ install.php [E]
如果 install.php 不存在,我可以将用户重定向到 install.php 但不能重定向到 index.php。
我不知道要检查 install.php 是否存在的 RewriteCond:
RewriteEngine On
RewriteBase /myscript/
RewriteCond ?? ??
RewriteRule ^ install.php [E]
感谢任何帮助。顺便说一句,我对 .htaccess 配置一点也不擅长。
更新:
感谢您的 cmets 和回复。是的,我知道我可以通过我的 php 脚本重定向,例如:
if(file_exists('install.php')){
header('Location: http://'.$domain.'/install.php');
}
但是我们可以对 .htaccess 做同样的事情吗?
【问题讨论】:
-
您可以改为加载 index.php(因为这将是您 99% 的时间使用的内容)并在该文件中检查 install.php 是否存在。如果是,那么
require( ... );那。 -
为什么要在 .htaccess 中这样做?只是为了好玩还是有什么特殊原因?
-
如果您不让他们进行 apache 配置,即使是通过 htaccess,许多安装您的应用程序的人都会喜欢它。有些不会启用 modrewrite,有些甚至可能无法使用 htaccess。
-
好的@ScottSaunders。著名的。 :)
标签: php regex apache .htaccess mod-rewrite