Home  >  Article  >  Backend Development  >  yii框架中get提交表单时生成的URL有关问题。

yii框架中get提交表单时生成的URL有关问题。

WBOY
WBOYOriginal
2016-06-13 11:50:02835browse

yii框架中get提交表单时生成的URL问题。。。。。。。
用GET提交表单的时候URL类似是这样的www.baidu.com/index.php/test?id=12

后面是?id=12

想问下在PHP或者YII框架里面,有什么办法把GET提交表单的时候URL变成www.baidu.com/index.php/test/id/12

就是 ?id=12 变成了 /id/12

请给位帮帮小弟了。
我用的是YII框架
------解决方案--------------------
表单的提交中,是由javascript构造的GET URL

/index.php/test/id/12 是Yii本身的一个路由规则,可在如下的文件中进行修改:
protected/config/main.php
将第41行至48号取消注释,即会使用 index.php/test/id/12 类似的路由规则。

这样,你提交到当前php应用的表单,相关的javascript会重新组织GET URL。
------解决方案--------------------
参考CUrlManager 默认情况下 访问路径是 index.php?r=index(控制器)/a(ACTION)/参数1/数据1/参数2/数据2

如果你想去掉index.php?r=xxx  在main.php中配置路由管理类 具体看一下上述类  有基本介绍 然后在改下.htaccess 即可!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn