1

I have a big problem with css and codeigniter.. I am starting to think it is my permissions or am I going mad?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

<title>test</title>
<link rel="stylesheet" href="<?php echo base_url(); ?>/css/style.css" 
     type="text/css" media="screen"/>
</head>

<body>

<?php echo base_url(); ?>css/style.css

This is my header file, and as you can see i've even echoed it out just to make sure it is right and it is, when I view source of the page it seems fine.. but somehow it is not doing anything, this is my css just to show you the background should be gray:

body{

background: #b6b6b6;
margin 0;
padding 0;
font-family: arial;
 }

my base url is fine.. as it is echoed out and goes to the right place $config['base_url'] = 'http://localhost/block/application';

I am really going mad what could be going wrong?

ht access:

Deny from all
5
  • ..."deny from all" means no one, even you, can access it. And you do need another slash like what Paul and Musa say. Commented Aug 2, 2012 at 21:57
  • I have added another slash and it is in there right now, but it hasnt fixed the problem yet, should I change whats in my htaccess? as far as I know this what CI has supplied me with by default.. Commented Aug 2, 2012 at 22:03
  • 1
    Ohhh. What is the folder that this htaccess file is in? And what is the folder your css is in? This htaccess prevents users from directly getting to a page. But all resource folders should have this: css, images, javascript, etc. Commented Aug 2, 2012 at 22:06
  • I have found out what it is :) my css folder was in the application bit, which CI seems to protect for its own good, I have moved it and changed the base url and everything is good now :) learned from my mistake! Commented Aug 2, 2012 at 22:16
  • If the base_url() is configured also try be removing base_url() from href and try directly for examle href="css/style.css" and href="js/js.css" etc without prefixing base_url() Commented Jul 4, 2021 at 12:15

7 Answers 7

2

If you want base_url() to output the proper url, simply pass in the path as a parameter.

base_url('path/to/stylesheet.css');
Sign up to request clarification or add additional context in comments.

7 Comments

Unfortunately this is not working, the page is forbidden though do you think it might be my permissions?
Barring a correct url, make sure permissions are at least 0644 (assuming linux/unix).
Permissions are 755 Have a look I have uploaded it.. : mintystudios.co.uk/ci/index.php/login I still can't figure it out!
Please post your .htaccess in your original question.
done it right at the bottom, it just has this in it: "Deny from all"
|
1

you can use

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

or

<link rel="stylesheet" href="<?php echo base_url('css/style.css'); ?>" 
type="text/css" media="screen"/

Comments

1

After trying so many things, what actually worked for me is to place the assets folder in the root directory NOT the application directory

Comments

0

If your base_url() gives you http://localhost/block/application then the path to the css file will look like http://localhost/block/applicationcss/style.css, I think it should be http://localhost/block/application/css/style.css, so you're missing a /

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

1 Comment

didnt work.. although the page is forbidden do you think it might be my permissions?
0

Add another / in your link /css/style.css

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

1 Comment

didnt work.. although the page is forbidden do you think it might be my permissions?
0

Don't have an htacess file with Deny From All in any resource folders.

You need to seperate out the css folder from the applications folder.

Comments

0

you must take the css folder or file and put it in the root directory not the application directory and use base_url function as i stated below

<link href="<?php echo base_url();?>site.css"

Comments

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.