dongteng2534 2017-07-19 08:34
浏览 17
已采纳

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

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 http://www.codecyan.com/omi/ifsc/about.html then the about.html file should be shown instead of passing it as http://www.codecyan.com/omi/ifsc/?branch=index.html

Demo website is: http://www.codecyan.com/omi/ifsc/

Thanks :)

  • 写回答

1条回答 默认 最新

  • dongpeiwei8589 2017-07-19 09:01
    关注

    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)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)