yii2路由去掉index.php
阿新 • • 發佈:2019-01-23
1.通常都是先更改Apache的Apache\conf\httpd.conf檔案中兩個配置
但是基本都是配置好的,則無需再配置了
2.在yii的config檔案下開啟main.php
新增程式碼
'components' => [ //...已有程式碼... 'urlManager' => [ 'enablePrettyUrl' => true, 'showScriptName' => false, 'suffix'=>'.html', ], 'log' => [ //... ],
3.在入口檔案統計目錄加入檔案:.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
若更改過Apache配置,重啟生效