im quite aware of Codeigniter but came across this problem while trying to convert a static site into CI. The problem happens while loading css files when certain urls are used. Im trying to strictly keep php away from views (infact want to have only .html pages for views).
I have also searched many forums for a solution for loading css. I have come across some solutions but they help only if you are making a completely new site in CI. I am aware of
using before the href link to make it site independant
but do not want to use this, cause i want to convert an existing static website into CI. which would mean changing each and every href at every file. (seems like a nightmare if there are many pages).
I am having trouble loading the css and other resource files in certain conditions. Below is a description of what all i have done so far in the project.
- used .htaccess at root to remove "index.php" file
- used standard folder structure that comes with codeigniter 2.0.2
- all images and resources (Eg. css, img, js . . . etc) are placed directly in the root folder (i.e. where the application & system folders are located)
- all resources are accessed from the view files as if the html files were in the root folder along with the resources (Eg. href="css/style.css")
Below is a sample description of the controller
class Blog extends CI_Controller {
public function index(){
$this->load->view('blog.html');
}
public function posts(){
$this->load->view('post.html');
}
}
Now the problem i am facing a problem is when i use certain url for the "index" function . . the css gets loaded correctly.
But if i add a slash after that or use any of the other functions. there is a problem loading the css.
Eg.
/* This url loads css correctly */
http://localhost/ci-test/blog
/* these urls do not load css */
http://localhost/ci-test/blog/
http://localhost/ci-test/blog/posts
Is there something i am doing wrong? or some problem with my .htaccess file ? (included below)
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
What do i need to do to import the current website into CI with minimal effort.