我已在Yii完成了一个网站。但问题是网站网址不是SEO友好的,并且没有找到它在谷歌搜索中的位置。我的网址为http://helll.com/Industries?id=1
我想将我的网址更改为http://helll.com/Industries/hospitality-and-tourism,即用帖子名称替换帖子ID,我已经有一个像这样重写的网址
'/Industries'=>'/lriIndustries/See',
就像这里What will be URL rewrite in yii url manager我改变了我的网址重写如下,但它似乎无法正常工作
'/Industries-<industries_name:.+>'=>'/lriIndustries/See',
echo $_GET['industries_name'];
答案 0 :(得分:0)
你忘记了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
}