I downloaded a html theme from a website and i’m trying to put it in my codeigniter project. I copy and pasted the .html file from the downloaded theme folder into my view “index_v.php”. I also copied the css folder directly into the views folder. The index_v.php file calls the .css file like this
<link rel="stylesheet" href="style.css">
Yet when I load the page it doesn’t load the .css file.
You’re probably running into an issue with relative paths. If your URL is
/users/welcome/, it’s looking for the file/users/welcome/style.cssSolutions:
Use a full URL:
<link rel="stylesheet" href="http://example.com/style.css">Use CI’s
link_tag()which will prepend your base url to the path<link rel="stylesheet" href="/style.css">If you are unable to access the file directly, check your .htaccess file if you are using it. Most CI installations use something like this:
With this rule, there are two files and one directory that are allowed direct access (index.php, a directory named public, robots.txt). The rest is routed through
index.php.It’s best to create a directory for all your static files (images, css etc.) and add this directory name to the exclusion list. Keeping those files in the directory root is just going to cause tons of clutter.