2011-08-13 1 views
1

저는 PHP로 작은 부트 스트랩을 만들려고합니다.PHP 부트 스트랩 파일을 만드는 중입니다. 파일에 액세스 할 수 없습니다.

내 DIRS는 다음과 같습니다

./application 
./application/_styles 
./application/_img 
./application/views 
./application/views/index 
./application/views/error 
./application/controllers/ 
./application/models/ 
./application/Bootstrap.php 
./.htaccess 

htaccess로 :

Options +FollowSymLinks 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^.*$ application/Bootstrap.php [NC,L] 

Bootstrap.php :

<?php 
#set up the project to developing state 
error_reporting(E_ALL); 
ini_set('display_errors','On'); 

#let's set up a root path constant 
define('ROOT',getcwd().DIRECTORY_SEPARATOR); 
#useful conf. 
define('IMG', ROOT.'views/_img/'); 
define('CSS', ROOT.'views/_styles/'); 

$projectUrl = "http://www.neophp.com/"; 
$siteUrl = "http://www.neophp.com"; 

class neoPHP{ 

    #== Method to get current URL request ==# 
    private function zinit(){ 
     #get variables 
     $host = $_SERVER['HTTP_HOST']; 
     $self = $_SERVER['REQUEST_URI']; 
     $query = !empty($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : null; 
     $url = !empty($query) ? "http://$host$self?$query" : "http://$host$self"; 
     #sort data 
     $request = str_replace($GLOBALS['projectUrl'], "", $url); 
     $request = explode("/",$request); 
     $request = array_filter($request); 
     #make readable 
     $load = array(); 
     foreach($request as $rq){ 
      $load[] = $rq; 
     } 
     #return information 
     return $load; 
    } 

    public function getClasses(){ 
     // create an array to hold directory list 
     $results = array(); 
     // create a handler for the directory 
     $handler = opendir(ROOT.'models/'); 
     // open directory and walk through the filenames 
     while ($file = readdir($handler)) { 
      // if file isn't this directory or its parent, add it to the results 
      if ($file != "." && $file != ".." && strstr($file, '.php')) { 
      $results[] = $file; 
      } 
     } 
     // tidy up: close the handler 
     closedir($handler); 
     // done! 

     foreach($results as $class){ 
      include_once (ROOT.'models/'.$class); 
     } 
    }  

    #== Method to load requred pages ==# 
    public function zinitLoad(){ 
     $this->getClasses(); 
     $items = $this->zinit(); 
     #include all models 
     global $neo; 
     global $users; 

      if(sizeof($items) == 0) { 
       if (file_exists(ROOT.'controllers/index/index.php') && file_exists(ROOT.'views/index/index.phtml')){ 
        include_once(ROOT.'controllers/index/index.php'); 
        include_once(ROOT.'views/layout/layout.phtml'); 
        include_once(ROOT.'views/index/index.phtml'); 
        include_once(ROOT.'views/layout/footer.phtml'); 
       } else {header('Location: '.$GLOBALS['projectUrl'].'error/');} 
      }elseif(sizeof($items) == 1) { 
       if (file_exists(ROOT.'controllers/'.$items['0'].'/index.php') && file_exists(ROOT.'views/'.$items['0'].'/index.phtml')){ 
        include_once(ROOT.'controllers/'.$items['0'].'/index.php'); 
        include_once(ROOT.'views/layout/layout.phtml'); 
        include_once(ROOT.'views/'.$items['0'].'/index.phtml'); 
        include_once(ROOT.'views/layout/footer.phtml'); 
       } else {header('Location: '.$GLOBALS['projectUrl'].'error/');} 

      } 
      elseif (sizeof($items >= 2)){ 
       if (file_exists(ROOT.'controllers/'.$items['0'].'/'.$items[1].'.php') && file_exists(ROOT.'views/'.$items['0'].'/'.$items[1].'.phtml')){ 
        include_once(ROOT.'controllers/'.$items['0'].'/'.$items[1].'.php'); 
        include_once(ROOT.'views/layout/layout.phtml'); 
        include_once(ROOT.'views/'.$items['0'].'/'.$items[1].'.phtml'); 
        include_once(ROOT.'views/layout/footer.phtml'); 
       } else {header('Location: '.$GLOBALS['projectUrl'].'error/');} 
      } 
    } 

    #== Method to print arrays ==# 
    public function show($arr){ 
     echo '<pre>';print_r($arr);echo '</pre>'; 
    } 

} 


$neo = new neoPHP(); 
$neo->getClasses(); 

$neo->zinitLoad(); 
//print_r(getDirectoryList(ROOT)); 
//if (class_exists('Users')) echo 'exists'; 



?> 

내 문제는 HTML 코드입니다. * .css 파일이나 * .png 파일을 호출하려고하면 스크립트가 오류 페이지로 돌아갑니다. 나는 생각했다

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

이 문제를 해결할 수는 없지만 그렇게하지는 않는다.

그래서이 설정으로 파일에 액세스하거나 다른 조언이 필요합니다. 나는 파일이 액세스와 같은 새로운 재 작성 규칙이 활성화 추가하는 경우

답변

2

이 보인다 :

Options +FollowSymLinks 
RewriteEngine On 
Rewriterule ^application/views/.*$ - [PT] 
RewriteRule ^.*$ application/Bootstrap.php [NC,L] 
관련 문제