2013-09-21 2 views
1

Yii 응용 프로그램에 대한 작업을 마무리하고 예쁘게 URL을 갖고 싶습니다. 나는 사이트와 Yii wiki에 인터넷 검색을 통해 갔고 설명서에 따라 갔다. 그러나, 나는 index.php 양식을 내 URL에 숨길 수없는 시점에 갇혀있다.Yii 404 오류 (urlmanager showscript with false)

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

내가 얻을 false로 설정 'showScriptName'와 함께 : 작동 내 URL에서 index.php를 통해 사이트가 열리고, 그것없이, 그것은 나에게 서버 (404)

를이 내 main.config됩니다 gices

이 (404) 내 htaccess로

RewriteEngine on 
RewriteBase/
# if a directory or a file exists, use it directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond $1 !^(index\.php) 

# otherwise forward it to index.php 
RewriteRule ^(.+)$ index.php?$1 [PT,L,QSA] 

나는 현재 WAMP를 사용하여 로컬 호스트에 사이트를 테스트하고있다. Apache의 Mod_rewrite가 실행 중입니다. http.conf를 Options Indexes FollowSymLinks Allow Override All로 변경했습니다.

그 밖의 무엇이 내가 뭘 놓치고 있습니까?

답변

1

고민중인 분! .htaccess를 보호 된 폴더가 아닌 응용 프로그램의 루트에 놓으십시오 !!! 당신의 .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 

에서

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

프로젝트 폴더에 htaccess로 업로드합니다. 추가

1

보십시오 : 당신의 urlManager '규칙'배열에

'' => 'site/index' 

. 논리에 따르면 Yii는 패턴 ''의 요청을 정의 된 규칙과 일치시킬 수 없습니다.