douduan2272 2014-08-19 14:30
浏览 31

htaccess重写规则无法访问直接文件

I have this in my .htaccess file:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteBase /
RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]

This works fine. e.g. when entering localhost/file it acts as if it was localhost/index.php?route=file

My problem however is that the server is set to serve files without the need to type .php as file extension. So when I access localhost/login, instead of doing localhost/index.php?route=login, it serves me the file login.php directly. How can I avoid that?

  • 写回答

1条回答 默认 最新

  • dongyuan9109 2014-08-19 14:31
    关注

    Simply disable MultiViews option.

    Replace your current code by this one

    Options -MultiViews
    
    RewriteEngine On
    RewriteBase /
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?route=$1 [L,QSA]
    
    评论

报告相同问题?

悬赏问题

  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失