2017-06-23 6 views
0

Ich bekomme einen Fehler 404 auf dem Server, wenn Sie versuchen, eine beliebige Seite zu laden. Die Homepage wird ohne Probleme geladen, auf localhost funktioniert alles einwandfrei.bekommen 404 nicht auf dem Server gefunden

Meine Route Klasse:

static function start() 
     { 
      $controller_name = 'add_task'; 
      $action_name = 'index'; 

      $routes = explode('/', $_SERVER['REQUEST_URI']); 

      if (!empty($routes[1])) 
      { 
       $controller_name = $routes[1]; 
      } 

      if (!empty($routes[2])) 
      { 
       $action_name = $routes[2]; 
      } 

      $model_name = 'Model_'.$controller_name; 
      $controller_name = 'Controller_'.$controller_name; 
      $action_name = 'action_'.$action_name; 

      $model_file = strtolower($model_name).'.php'; 
      $model_path = "application/models/".$model_file; 
      if(file_exists($model_path)) 
      { 
       include "application/models/".$model_file; 
      } 

      $controller_file = strtolower($controller_name).'.php'; 
      $controller_path = "application/controllers/".$controller_file; 
      if(file_exists($controller_path)) 
      { 
       include "application/controllers/".$controller_file; 
      } 
      else 
      { 
       Route::ErrorPage404(); 
      } 

      $controller = new $controller_name; 
      $action = $action_name; 

      if(method_exists($controller, $action)) 
      { 
       $controller->$action(); 
      } 
      else 
      { 
       Route::ErrorPage404(); 
      } 

     } 

     function ErrorPage404() 
     { 
      ... 
     } 
    } 

Meine .htaccess-Datei:

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule .* index.php [L] 

Ich kann nicht verstehen, wo das Problem

Antwort

0

dieses htaaccess mein Problem wurde gelöst durch die Verwendung:

<IfModule mod_rewrite.c> 
     <IfModule mod_negotiation.c> 
      Options -MultiViews 
     </IfModule> 

     RewriteEngine On 

     # Redirect Trailing Slashes If Not A Folder... 
     RewriteCond %{REQUEST_FILENAME} !-d 
     RewriteRule ^(.*)/$ /$1 [L,R=301] 

     # Handle Front Controller... 
     RewriteCond %{REQUEST_FILENAME} !-d 
     RewriteCond %{REQUEST_FILENAME} !-f 
     RewriteRule^index.php [L] 

     # Handle Authorization Header 
     RewriteCond %{HTTP:Authorization} . 
     RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 
    </IfModule> 
Verwandte Themen