2017-07-19 08:34



I am developing an IFSC code finder script.

I have some files already named about.php, privacy-policy.php, contact-us.php and some other files and folders. My .htaccess file content is:

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]

Now, I want that the files which are already existing like about.html or about.php and so on should be shown instead of passing the query to custom rewrite condition. For example when I try to visit then the about.html file should be shown instead of passing it as

Demo website is:

Thanks :)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • dongpeiwei8589 dongpeiwei8589 4年前

    Taking inspiration from this other answer, you should probably check beforehand if the requested file (not folder) exists, then skip all rewriterules if it does.

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

    (I'm not a guru in mod_rewrite, please double-check)

    点赞 评论 复制链接分享