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 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法
  • ¥15 可否在不同线程中调用封装数据库操作的类
  • ¥15 微带串馈天线阵列每个阵元宽度计算
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏