dongqixuan3112 2015-11-17 20:01
浏览 29

IIRF / .htaccess删除扩展名,但保留查询字符串

I'm using Ionics Isapi Rewrite Filter on an older server and need to rewrite some URL's...

My current rules are:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L,QSA]

And this works for URL's like http://www.my-site.co.uk/login, http://www.my-site.co.uk/contact

But, if I have http://www.my-site.co.uk/login?result=fail (for example), then I just get a 404 response.

I was initially missing the 'QSA', but adding it didn't help.

I've tried:

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^([^\.]+)$ $1.php?%1 [NC,L,QSA]

(from htaccess remove .php and keep query string), and various combinations of:

RewriteCond %{REQUEST_FILENAME}.php -f

But without success. I've been through most of the suggestions on StackOverflow, none of them appear to work. Does anyone have any ideas?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算