2012-07-24 3 views
0

cakephp 1.3에서 코딩 중입니다. 페이지를 index.html로 리디렉션하는 중 문제가 있습니다.경로가 index.html 페이지로 리디렉션되지 않음

내 index.html은 webroot 폴더 안에 있습니다. cakephp가 index.html로 직접 리디렉션된다는 것을 알고 있습니다.

나는 그것이 오류를 보여주는 URL을 사용하여

..

Error: Controller could not be found. 

Error: Create the class Controller below in file: app/controllers/controller.php 

<?php 
class Controller extends AppController { 

    var $name = ''; 
} 
?> 

나는 몇 가지 링크를 따라했지만 작동하는 것 같다 없습니다. Google에서도 확인했습니다.

How can I append .html to all my URLs in cakephp?

답변

1

당신은 작동이 중지됩니다 CakePHP의 자신의 index.php 또는 CakePHP의를 대체 할 수 없습니다. 일반적으로 webroot에 파일을 넣을 수는 있지만 문제없이 작동하지만 루트 파일은 Cake의 라우팅을 CakePHP가 아닌 파일을 표시하는 데에만 사용할 수 없으므로 조금 더 까다 롭습니다.

html 파일을 컨트롤러의보기에두고 루트 디렉토리를 라우트하십시오. 예를 들어 index.ctp 파일의 이름을 app/views/static_pages/index.ctp에 지정합니다.

라우터 :

Router::connect('/', array('controller' => 'static_pages', 'action' => 'index')); 

컨트롤러 (static_pages_controller.php) :

class StaticPagesController extends AppController { 
    function index() { 
     // no need to do anything except use no layout file 
     $this->layout = false; 
    } 
} 

모델 (static_page.php) :이 시도됩니다 @Juhana

class StaticPage extends AppModel { 
    // don't use a database for this model 
    var $useTable = false; 
} 
+0

감사합니다! –

+0

+1 귀하의 도움을 .. –

관련 문제