【发布时间】:2011-09-12 11:27:34
【问题描述】:
我希望使用 .htaccess 根据目录中是否存在文件来重定向到一个页面或另一个页面。
基本上,如果 splash.php 不存在,我需要将 index.php 的所有访问者发送到 home.php 页面,或者如果 splash.php 存在,我需要将所有访问者发送到 splash.php 页面strong> 存在于目录中,目前我有这个...
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} index.php
RewriteCond %{DOCUMENT_ROOT}/splash.php -f
RewriteCond %{SCRIPT_FILENAME} !splash.php
RewriteRule ^.*$ /splash.php [L]
只有当我明确将 mysite.com/index.php 作为我的 URL 时,它才会将访问者发送到 mysite.com/splash.php,如果只使用 mysite.com URL,它将不起作用。
我了解我的代码的前 3 行,但不了解 !splash.php -f 位(我是从我在 SO 上找到的其他重定向代码中得到的)。
如果 splash.php 不存在,我如何重定向到 home.php?
干杯!
【问题讨论】:
标签: php apache .htaccess mod-rewrite redirect