为了SEO做到优化,我觉得URL不应该出些module name,controller name。只应该出现文章的slug.
我自己的小说站是这说设计的
http://www.x.com/gulong 作者古龙的信息
http://www.x.com/xiaolifeidao 小说《小李飞刀》的具体内容。
http://www.x.com/youxiuzhuojiapaiming 这是一个论坛的版块《优秀作家排名》
我会有一个system_slug表。
根据slug表查询出这篇文章的是属于news模块,还是属于小说模块。
SystemController {
public funciton distributionController($slug)
{
$module = "select moduleName from system_slugs where slug='slug';
$contoller = "select contollerName from system_slugs where slug='slug';
return $module::$contollerName($slug);
}
}
1,我这个小说站用的是Laravel,很方便这样写。如果换成Yii2的,这样写行得通吗,(下一个项目比较大,也比较长久,已经决心用Yii2,Yii2的路由分配好像不足够灵活?)
2,这种模式来优化seo有没有问题啊?
3,我在国外的stackflow上看到有人提这个问题。有人回答说最好用restfull来处理这样设计,我不懂。用restfull怎么就更有利于实现这样的想法呢?
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
认证高级PHP讲师