我已经在Yii中完成了一个网站。但问题是网站URL对SEO不友好,在谷歌搜索中找不到它的位置。我的URL为http://helll.com/Industries?id=1
我想把我的网址改为http://helll.com/Industries/hospitality-and-tourism也就是说,用帖子名称替换帖子id,我已经有了一个类似的url重写
'/Industries'=>'/lriIndustries/See',
像这里一样,yii URL管理器中的URL重写是什么我已经更改了我的URL重写如下,但它似乎不起作用
'/Industries-<industries_name:.+>'=>'/lriIndustries/See',
echo $_GET['industries_name'];
您忘记了Industries和Industries_name之间的斜线。
'/Industries/<industries_name:.+>'=>'/lriIndustries/See',
您还必须在lriIndustriesController中使用urlFormat => 'path'
和actionSee($industries_name)启用urlMangager才能完成此工作。
为什么到处都在回响$_GET['industries_name']?您不发送任何GET变量。必须将$industries_name变量传递给actionSee(在lriIndustriesController中)。
public function actionSee($industries_name)
{
//find Industry by name and show it
}