我正在开发一个IFSC代码查找器脚本。
我有一些文件已经命名为about.php
,privacy-policy.php
,contact-us.php
以及其他一些文件和文件夹。我的.htaccess
文件内容为:
RewriteEngine on
RewriteRule ^index.html$ index.php [L]
RewriteRule ^about.html$ about.php [L]
RewriteRule ^privacy-policy.html$ privacy-policy.php [L]
RewriteRule ^contact-us.html$ contact-us.php [L]
RewriteRule ^search.html$ search.php [L]
RewriteRule ^(.*)/(.*)/(.*)/(.*)/?$ index.php?bank=$1&state=$2&district=$3&branch=$4 [QSA]
RewriteRule ^(.*)/(.*)/(.*)/?$ index.php?bank=$1&state=$2&district=$3 [QSA]
RewriteRule ^(.*)/(.*)/?$ index.php?bank=$1&state=$2 [QSA]
RewriteRule ^(.*)/?$ index.php?bank=$1 [QSA]
现在,我希望显示已存在的文件,如about.html
或about.php
等,而不是将查询传递给自定义重写条件。例如,当我尝试访问http://www.codecyan.com/omi/ifsc/about.html时,应显示about.html文件,而不是将其作为http://www.codecyan.com/omi/ifsc/?branch=index.html传递
演示网站是:http://www.codecyan.com/omi/ifsc/
谢谢:)
答案 0 :(得分:1)
从this other answer获取灵感,您应该事先检查所请求的文件(不是文件夹)是否存在,然后跳过所有重写文件。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+) - [PT,L]
(我不是mod_rewrite的大师,请仔细检查)