我无法看到现有文件内容htaccess

时间:2017-07-19 08:34:22

标签: php apache .htaccess mod-rewrite

我正在开发一个IFSC代码查找器脚本。

我有一些文件已经命名为about.phpprivacy-policy.phpcontact-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.htmlabout.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/

谢谢:)

1 个答案:

答案 0 :(得分:1)

this other answer获取灵感,您应该事先检查所请求的文件(不是文件夹)是否存在,然后跳过所有重写文件。

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.+) - [PT,L]

(我不是mod_rewrite的大师,请仔细检查)