0

我已经在 Yii 中完成了一个网站。但问题是网站网址对 SEO 不友好,并且在谷歌搜索中找不到它的位置。我的网址为http://hellll.com/Industries?id=1

我想将我的网址更改为http://hellll.com/Industries/hospitality-and-tourism,即用帖子名称替换帖子 ID,我已经有这样的网址重写

'/Industries'=>'/lriIndustries/See',

像这里yii url manager 中的 URL rewrite 会是什么我已经将我的 url rewrite 更改如下,但它似乎不起作用

'/Industries-<industries_name:.+>'=>'/lriIndustries/See',
echo $_GET['industries_name'];
4

1 回答 1

0

您忘记了 Industries 和 Industries_name 之间的斜线。

'/Industries/<industries_name:.+>'=>'/lriIndustries/See',

您还必须在 lriIndustriesController 中启用 urlMangagerurlFormat => 'path'和 actionSee($industries_name) 才能完成这项工作。

你为什么到处回显 $_GET['industries_name'] ?您不发送任何 GET 变量。您的 $industries_name 变量必须像这样(在 lriIndustriesController 中)传递给 actionSee。

public function actionSee($industries_name)
{
    //find Industry by name and show it
}
于 2013-12-02T05:08:19.300 回答