yii2.0 url美化-apache服務器

//配置內容php

'urlManager' => [
  'enablePrettyUrl' => true,
  'enableStrictParsing' => false, //不啓用嚴格解析
  'suffix' => '',
  'showScriptName' => false,
  'rules' => [
    '<controller:\w+>/<id:\d+>'=>'<controller>/view',
    '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
    '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
  ],
],url

在根目錄下,添加.htaccess文件,內容以下code

#Options +FollowSymLinksip

#IndexIgnore /
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
相關文章
相關標籤/搜索