1

I am working on a codeigniter project. I am having a problem about css. the css are included in the header in the following fashion:

<link  href="http://localhost/ebookazine/assets/css/reset.css" rel="stylesheet" type="text/css" />
<link  href="http://localhost/ebookazine/assets/css/typography.css" rel="stylesheet" type="text/css" />
<link  href="http://localhost/ebookazine/assets/css/FlashStatus.css" rel="stylesheet" type="text/css" />
<link  href="http://localhost/ebookazine/assets/css/webshop.css" rel="stylesheet" type="text/css" />

but no css links are working. someone help about this?

6
  • 2
    Open one of them directly in the browser's address bar. What happens? Commented Aug 21, 2011 at 7:35
  • 1
    Do you get http://localhost/ebookazine/assets/css/reset.css when you go there with a browser directly? Commented Aug 21, 2011 at 7:38
  • Do you see the problem on your local machine or when you upload your site to a server? You CSS is references with absolute urls. Commented Aug 21, 2011 at 7:46
  • I would venture to guess that OP is using an .htaccess that's not allowing files in /assets to be directly accessed. However, why we are being forced to guess is anyone's guess. StoneGarden, here are several people eager to help you. You had an inquiry 3 minutes after posting, please pay attention to your active questions. Commented Aug 21, 2011 at 7:55
  • localhost/ebookazine/assets/css/reset.css ---- no, this gives "not found" Commented Aug 21, 2011 at 8:05

2 Answers 2

5

First of all, check if your .htaccess file looks something like this (especially the |assets| part is important):

rewriteengine on
rewritecond $1 !^(index\.php|assets|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]

This allows that the files inside your assets folder can be accessed by public.

Next, make sure that the paths inside your view use the base_url() command, e.g.:

<link href="<?php echo base_url(); ?>assets/css/typography.css" rel="stylesheet" type="text/css" />

With that, the view will always use the correct absolute URL, no matter if you are testing it on your local machine or on a webserver.

Sign up to request clarification or add additional context in comments.

1 Comment

+1 Probably .htaccess issue. See also: link_tag()
0

Try copying the code found within the css files and creating new css files on your computer and then pasting the code(the code you just copied) into those files(the new files you just created). Make sure you put the new css files in the same folder as your html file. Then, simply link the css files in the following fashion:

<link rel="stylesheet" type="text/css" href="filename.css"/>

I honestly don't know why it's not working the way you're doing it at the moment; i would need to know more information in order to help you if you really want to leave the files where they currently are(in localhost).

2 Comments

i am using codeigniter framework and hmvc pattern. so, this is important to keep the css in that folder.
I've never used that framework before, unfortunately i can't help you there. It might be easier to just keep the files in your html file folder, i don't know what your goal is, but that's my only suggestion at the moment. Good luck though!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.