重写规则的index.php?/控制器/方法/参数为/控制器/方法/参数 [英] Rewrite rule index.php?/controller/method/param to /controller/method/param

查看:103
本文介绍了重写规则的index.php?/控制器/方法/参数为/控制器/方法/参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个重写规则这个网址

I need a rewrite rule for this url

http://localhost/~user/frame/lib/index.php?/controller/method/12/22/

我怎样才能重写它,我可以这样调用

How can i rewrite it that i can call it like this

http://localhost/~user/frame/lib/controller/method/12/22/

什么是上述问题的重写规则?
我希望我能解释清楚我的问题。

What is the rewrite rule for the above problem? I hope i could explain my question clear.

推荐答案

试试这个规则:

RewriteRule $2 !^index\.php$
RewriteRule ^(/~[^/]+/[^/]+/[^/]+)(/.*)? $1/index.php?$2

根据您要使用此规则(我的建议是为服务器/虚拟主机配置),您可能需要从模式中删除上下文路径preFIX。所以,如果你想使用规则中的 .htaccess文件/〜用户/ 的:

Depending on where you want to use this rule (my suggestion is meant for the server/virtual host configuration), you may need to remove the contextual path prefix from the pattern. So if you want to use the rule in the .htaccess file in /~user/:

RewriteRule $2 !^index\.php$
RewriteRule ^([^/]+/[^/]+)(/.*)? $1/index.php?$2

或者,如果在的 /〜用户/帧/ lib目录/ 的:

RewriteRule $0 !^index\.php$
RewriteRule .* index.php?/$0

这篇关于重写规则的index.php?/控制器/方法/参数为/控制器/方法/参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆