我在前端有模块,我想制作一个友好的网址:
//yourdomain/a-zA-Z_module-controller-action-id-page-1.html
如此链接:
http://kudufood.com/com-van-phong-lam-the-nao-de-nau-canh-bong-cai-duoc-ngon-kudu_cookbooks_1429067720.html
答案 0 :(得分:0)
您可以通过将以下代码添加到config / web.php中的应用程序组件并在“规则”中配置自定义URL来启用漂亮的URL:
'components' => [
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName'=>true,
'rules' => [
// your rules go here
'customURL'=>'my-controller/my-action'
],
如果你想隐藏index.php,请设置:
'showScriptName'=>false
并在/ web目录中创建 .htaccess 文件,其中包含以下内容:
RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
文档:http://www.yiiframework.com/doc-2.0/yii-web-urlmanager.html