html - PHP CodeIgniter CSS -


i downloaded html theme website , i'm trying put in codeigniter project. copy , pasted .html file downloaded theme folder view "index_v.php". copied css folder directly views folder. index_v.php file calls .css file this

<link rel="stylesheet" href="style.css">  

yet when load page doesn't load .css file.

you're running issue relative paths. if url /users/welcome/, it's looking file /users/welcome/style.css

solutions:

  • use full url: <link rel="stylesheet" href="http://example.com/style.css">

  • use ci's link_tag() prepend base url path

  • use absolute path: <link rel="stylesheet" href="/style.css">

if unable access file directly, check .htaccess file if using it. ci installations use this:

rewritecond $1 !^(index\.php|public|robots\.txt) rewriterule ^(.*)$ /index.php?/$1 [l]  

with rule, there 2 files , 1 directory allowed direct access (index.php, directory named public, robots.txt). rest routed through index.php.

it's best create directory static files (images, css etc.) , add directory name exclusion list. keeping files in directory root going cause tons of clutter.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -