[size="2"]To remove the [/size]initial[size="2"] index.php from all of your [/size]URL[size="2"]s read this [/size]http://www.bsourceco…iframework-2-0/
You should read this routing and URL creating docs http://www.yiiframew…me-routing.html it shows you all of this and discusses performance and other issues.
One thing to consider is that you do not allow for any controllers to match the name of your categories, sub categories or products or you will end up with links that don’t work. You will need to figure out how you want to handle this. Maybe do a validation rule that doesn’t allow for certain words. You could also prefix all of your categories, sub categories, and products with the id to avoid having to do that but it won’t match your desired output.
In the URL you will need to have a way to get your category,subcategory, and product names to the URLs.
You will need to have a field in each of your tables that will hold the url slug. A easy way to create these is to use the slugable behavior http://www.yiiframew…lebehavior.html. You will need to be careful as you are trying to create SEO friendly pages and when a slug changes your page URL will change. If it was indexed by a search engine you could loose some rank. A way to avoid this is to add the id like i stated above. This will match the id and not the slug so if the slug changes the url will always work because the id never changes. for example look at the stack overflow url https://stackoverflo…-url-a-bad-idea it has the id in the URL as does Google, Facebook etc. so it’s just a matter of research and preference for your application. I personally use ID in the URLs.
Url Manager
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
//all of your urls have .html so this is here but you can remove it if you don't want it
'suffix' => '.html',
'rules' => [
//need to be in order so you don't match the wrong url
//your url is not proper for category list it is ...list/&id=1 and should be list&id=1
'<category:\w+>' => 'category/list',
'<category:\w+>/<subcategory:\w+>' => 'subcategory/list',
'<category:\w+>/<subcategory:\w+>/<name:\w+>' => 'product/detail'
]
]
Controller actions
//category list
public function actionList($id,$category){
}
//subcategory list
public function actionList($id,$category,$subcategory){
}
//product detail
public function actionDetail($id,$category,$subcategory,$name){
}
Create a URL
//category list
Url::to(['/category/list','id'=>$id,'category'=>$category]);
//subcategory list
Url::to(['/subcategory/list','id'=>$id,'category'=>$category, 'subcategory'=>$subcategory]);
//product detail
Url::to(['/product/detail','id'=>$id,'category'=>$category, 'subcategory'=>$subcategory,'name'=>$name]);