I'm new in Yii2 so I have Brands table with their types ('brand', 'author', 'company')
and their slug name so I need the URL like that www.site.com/{brand_type}/{brand_slug}
without controller name so how to do that ?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
This is commonly called pretty URLs. To do achieve that in Yii2 put this in your app config file under
'components'
keyThe result is that when you passed a URL in the format you specified, your controller will
$type
and$slug
as parameters you can use in your controller which is expected to take the form:Notice that you will need your web server to configure executing your app's
index.php
even if it is not in the URL. For Apache this can be done, for example, using .httaccess (More details here) :The Definitive Guide to Yii 2.0 has an excellent section about this topic