I have made my own php MVC and it works perfectly for everything except when it comes to loading certain images. For example it will load like icons, and some other images but when it comes to using the tag it wont load the image but when i look in the google chrome developer inspector tool it shows that my tag images aren't loading. Its giving back a 301 number and loading the HTML. So in terms its like my MVC is thinking the URL for the image is a page!I want my MVC to only make requests to my index.php file which is in the root directory for my site. Also when it comes to it generating the HTML code i mean that it going to my error html page when i put the direct image url in the browser. Absolute URL for the image:
http://localhost/website/user_data/cfedabd2e283c19c06f3b8b5bd45df4bb66c2b3a/photo.jpg
Here is my code below:
.htaccess--
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?u=$1 [PT,L]
</IfModule>
bootstrap.php(Router)--
class Bootstrap {
function __construct() {
$url = $_GET['u'];
$url = rtrim($url, '/');
$url = explode('/', $url);
if (empty($url[0])) {
require 'controllers/index.php';
$controller = new Index();
$controller->index();
return false;
}
$file = 'controllers/' . $url[0] . '.php';
if (file_exists($file)) {
require $file;
} else {
$this->error();
}
$controller = new $url[0];
$controller->loadModel($url[0]);
// calling methods
if (isset($url[2])) {
if (method_exists($controller, $url[1])) {
$controller->{$url[1]}($url[2]);
} else {
$this->error();
}
} else {
if (isset($url[1])) {
if (method_exists($controller, $url[1])) {
$controller->{$url[1]}();
} else {
$this->error();
}
} else {
$controller->index();
}
}
}
function error() {
header('location: ' . APP_URL . 'index');
}
index.php(Where i want all the requests to go)--
<?php
//error_reporting(E_ALL);
session_start();
/* Require all config files */
require 'config/config.php';
/* Initiate system */
$bootstrap = new Bootstrap;
?>
Example What the user sees--
<h3>Error page not found</h3>
The image with
$photo = "http://localhost/website/user_data/cfedabd2e283c19c06f3b8b5bd45df4bb66c2b3a/photo.jpg;
<img src="<?php echo $photo; ?>" width="200" style="max-height: 200;"/>