關於Yii2.0的url路徑優化問題(配置虛擬路徑)


backend/config/main.php

'urlManager' => [

    'enablePrettyUrl' => true,
    'showScriptName' => false, 
    'enableStrictParsing' => false,
    'suffix' => '.html',
        'rules' => [
            '<controller:\w+>/<id:\d+>' => '<controller>/view',
        ],
],

如果在web文件夾下增加一個.htaccess文件,配置如下:

Options +FollowSymLinks 

IndexIgnore */* 

RewriteEngine on  
# if a directory or a file exists, use it directly 
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
 
RewriteRule . index.php

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM