I am working on creating my own structure and focus on learning more advanced programming methods than in college. I use .htaccess to redirect the entire page request to my boot file, which loads the controllers and themes based on the request URI.
URL format site.com/Controller[/optional/multiple/params]
The problem is, let's say I'm trying to include an image or css file, and it does not exist. In firebug they will not display as 404 errors due to redirection.
.htacess file
Options +FollowSymLinks IndexIgnore */* # Turn on the RewriteEngine RewriteEngine On # Redirect to index.php RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php
I check and parse the URIs and it forwards the 404 controller and generates a 404 header for the requested URI. However, for embedded files, such as CSS, images, etc., They show the same answer as the requested page, and will not generate 404 errors.
I.E. if you go to index.php, index.php will load fine, but all invalid css files will have the same header response as index.php.
Here is the code that the controller loads after parsing the URI:
//locate $file = 'Lume/' . self::$AppPath . 'Controller/' . self::$ControllerName; if(!file_exists($file . '.php')){ header('HTTP/1.0 404 Not Found'); $file='Lume/' . self::$AppPath . 'Controller/_404.php'; } //create $controller = str_replace('/', '\\', '/' . $file); if(!is_subclass_of($controller, '\Lume\Abstracts\Controller')) throw new \Exception('Route::Main The controller must extend from Lume\Abstracts\Controller'); self::$Controller =& new $controller();
source share