1
votes

I have CI installed on Godaddy subdomain in www.mydomain.com/test My home page loads as well as a link to my /news page

the problem I'm having is I can't get any images to load or my CSS files to load. I'm calling my CSS from my header file by:

<link rel="stylesheet" type="text/css" href="<?php echo base_url() ?>inc/css/base.css" media="all"/> 

I'm calling my header image by:

<img src="images/logo.png">

when I right click on X where image should be, and choose open in new tab so i can see what url it's pointing to... it seems good. http://mydomain.com/test/images/logo.png

I echoed my site_url and base_url and they seem configured correctly pointing to: http://www.mydomain.com/test/

my structure is: /test

1 index.php

2 .htaccess

3 /system

4 /application

  • /controllers
  • /images
  • /inc
    --- /css
    --- /js
  • /views

after reviewing stackoverflow questions... I pasted my .htaccess that sits in my www.mydomain.com/test folder with CI to be:

RewriteEngine On
RewriteBase /test

RewriteCond %{REQUEST_URI} ^system.*
RewriteCond $1 !^(index\.php|images|robots\.txt)

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /test/index.php?/$1 [L]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

my config.php is:

$config['base_url'] = 'http://www.mydomain.com/test/';

$config['index_page'] = "";

$config['uri_protocol'] = "AUTO";

1
if you manually type "mydomain.com/test/images/logo.png" into your browser - does the image load? - Laurence

1 Answers

1
votes

I have made a minor change in your code.

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

Concept: base_url() returns your site base URL, as specified in your config file. Example:

echo base_url();

This function returns the same thing as site_url, without the index_page or url_suffix being appended.

Also like site_url, you can supply segments as a string or an array. Here is a string example:

echo base_url("blog/post/123");

The above example would return something like:

http://example.com/blog/post/123

For more details, you can read the URL helper Guide on CodeIgniter's Website: URL Helper Guide