Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Yii2 URL管理器规则_Php_Url_Yii2_Rules - Fatal编程技术网

Php Yii2 URL管理器规则

Php Yii2 URL管理器规则,php,url,yii2,rules,Php,Url,Yii2,Rules,我在yii2中使用URLManager规则创建漂亮url时遇到问题 我的SiteContoller有actionProduct($slug)并生成url:http://localhost/myweb/web/site/product?slug=new-产品名称,我想创建如下url:http://localhost/myweb/web/produkt/new-product-name 我尝试使用一些规则: “站点/产品/”=>“产品/”, '/'=>produkt', '/'=>produkt'

我在yii2中使用URLManager规则创建漂亮url时遇到问题

我的SiteContoller有
actionProduct($slug)
并生成url:
http://localhost/myweb/web/site/product?slug=new-产品名称
,我想创建如下url:
http://localhost/myweb/web/produkt/new-product-name

我尝试使用一些规则:

  • “站点/产品/”=>“产品/”,
  • '/'=>produkt',
  • '/'=>produkt',
  • '/site/product/'=>produkt',

但是它不起作用。

尝试将
作为左侧URL规则的一部分。

对不起,但是URL规则的左侧部分如何<代码>''=>'produkt'或类似于
/=>'produkt'
?取决于所需的规则。例如:
'site/product/'=>'site/product',
ok,它可以工作。但当我将其更改为
'site/product/'=>'produkt'
时,仍然不起作用
'produkt'
表示默认情况下规则将其映射到
produkt/index
。您是否有
ProduktController
actionIndex($slug)
?没有。但是我可以创建自定义规则吗?其他框架允许这样做