Reputation: 72
I am learning MVC in PHP. The css and js files are not working in php pages.
I am using eclipse, xampp server.
This is my .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME)} !-d
RewriteCond %{REQUEST_FILENAME)} !-f
RewriteCond %{REQUEST_FILENAME)} !-l
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
this is my bootstap.php
<?php
class Bootstap {
function __construct() {
$url = isset($_GET ['url'])?$_GET ['url']:null;
$url = rtrim($url,'/');
$url = explode ( '/', $url );
// print_r ( $url );
if (empty($url[0])){
require 'controllers/Index.php';
$controller = new Index();
return false;
}
$file = 'controllers/' . $url [0] . '.php';
//print_r ( $file );
if (! file_exists ( $file )) {
require 'controllers/Error.php';
$controller = new Error ();
return false;
}
require "$file";
$controller = new $url [0] ();
if (isset ( $url [1] )) {
if (isset ( $url [2] ))
$controller->$url [1] ( $url [2] );
else
$controller->$url [1] ();
}
}
}
How do I resolve this issue?
Upvotes: 0
Views: 891
Reputation:
RewriteEngine On
RewriteBase /clients
RewriteRule ^(css|images|scripts|js|png|jpg) - [QSA,L]
Upvotes: 1
Reputation: 579
Where you have included your CSS/JS files?
As far as my knowledge, its not anything relates with .htaccess
and MVC
, in MVC
, your basic css/js files
are included in normal way like hows we are including with core PHP
(with html start head tag etc..)
I would recommend here to run your page in browser, and check view source. you must find out css/js pahts in source and issue can be here for wrong path (location not exactly set for public file includes), you can just correct and set right full path there to solve it
Upvotes: 0
Reputation: 2798
if you have a bad rewrite for css,img..., then you add this line into your htaccess file up to your rule
RewriteRule ^(css|images|scripts|js|png|jpg) - [L]
Upvotes: 0