yii url manager 中的 URL 重写是什么 [英] What will be URL rewrite in yii url manager

查看:29
本文介绍了yii url manager 中的 URL 重写是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经url重写

'compagnies' => 'site/compagnies',

我想转换可以接受格式的url

I want to convert url which can accept format like

http://www.example.com/compagnies-abc-def.com

http://www.example.com/compagnies-kdlsfj.com

http://www.example.com/compagnies-fdsf_sdf

在yii url manager中怎么写?

How can I write it in yii url manager?

推荐答案

使用:

'compagnies-<identifier:.+>' => 'site/compagnies',

然后您将能够使用 $_GET 访问 identifier 值,例如,如果 URL 是 compagnies-test ,您将能够像这样访问网址的测试"部分:

You will then be able to access the identifier value using $_GET, for example, if the URL is compagnies-test , you will be able to access the "test" portion of the url like so:

echo $_GET['identifier']; // echo's test

这篇关于yii url manager 中的 URL 重写是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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