2016-11-20 89 views
0

.htaccess內容爲波紋管:Yii Framework如何隱藏index.php?

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/$1 [L,QSA] 

和url經理是:

'urlManager' => array(
     'urlFormat' => 'path', 
     'showScriptName' => false, 
     'urlSuffix' => '.jsp', 
     'caseSensitive' => false, 

但是當我訪問所有子頁面和鏈接除了主頁,沒有的index.php它不工作。 如何解決這個問題?

回答

0
Set main.php in your yii configuration, at component : 

'urlManager'=>array(
'urlFormat'=>'path', 
'showScriptName'=>false, 
'caseSensitive'=>false,   

),

如果不工作,你可以添加下面的腳本到主配置文件urlManager陣列。

例如。 -

'routeVar'=>'route' 
+0

意味着我應該刪除保護/配置/ main.php的[url經理塊] 'urlSuffix'? – jones

0

請修改了htaccess文件與下面的代碼

Options +FollowSymLinks 
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 
#RewriteRule ^(.*)\?*$ index.php/$1 [L,QSA] 

和更改與下面的代碼

'urlManager' => array(
    'urlFormat' => 'path', 
     'showScriptName'=>false, 
     'rules' => array(
      '<controller:\w+>/<id:\d+>' => '<controller>/view', 
      '<controller:\w+>/<action:\w+>/<id:\d+>' => '<controller>/<action>', 
      '<controller:\w+>/<action:\w+>' => '<controller>/<action>', 
     ), 
    ),