我正嘗試從Yii上的網址中刪除/site/和/user/。我試圖添加此代碼yii從url中移除子文件夾字符串
'contact' => array('site/contact', 'caseSensitive'=>false),
但我仍然無法得到它的工作。我試圖讓我的所有靜態頁面看起來像mydomain.com/about.html
這裏有一些網址我想改變
/site/page?view=about ==> mydomain.com/about.html
/site/contact.html ==> mydomain.com/contact.html
/user/login.html ==> mydomain.com/login.html
這裏是要我走到這一步,
'urlManager'=>array(
'urlFormat'=>'path',
'urlSuffix'=>'.html',
'rules'=>array(
'<controller:\w+>/<id:\d+>'=>'<controller>/view',
'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
'<action:.*>'=>'site/<action>',
'user/<controller:\w+>/<action:\w+>'=>'user/<controller>/<action>',
),
'showScriptName' => false,
),
這是我的.htaccess
# Turning on the rewrite engine is necessary for the following rules and features
# FollowSymLinks must be enabled for this to work
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
</IfModule>
# Unless an explicit file or directory exists, redirect all request to Yii entry script
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</IfModule>