(html | php)不存在,通过htaccessredirect到URL

如果在主目录中不存在index.html或index.php文件,是否可以将(通过Rewrite Cond?)用户redirect到另一个URL以获得帮助?

感谢Greg

RewriteCond-f模式可以检查文件是否存在。 你可以用它来testing一个文件的存在。 例如,如果用户请求一个没有索引的目录,你可以用这些行的东西来redirect它们:

 RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{REQUEST_FILENAME}/index\.(html|php) !-f RewriteRule ^ http://example.com/something-blew-up.html [R=302]