0

I have this function

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Profile extends CI_Controller {

    public function __construct(){
            parent::__construct();
           $this->load->library('session');
           $this->load->helper('form');
           $this->load->model('Mdl_profile');
           $this->load->helper('string');
       }
    function index(){

            $this->load->view('buttons/welcome');
        }

        function success(){
            $this->load->view('buttons/welcome2');
        }
}

The problem is, when i go to profile/success the CSS is not loading. in inspect element the path of the css is localhost/project/profile/css/style.css instead of localhost/project/css/style.css.

I have a .htaccess file with this

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css|design|img|js)
RewriteRule ^(.*)$ /a-cat/index.php/$1 [L]
</IfModule>
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
ShelðÔn Alag
  • 367
  • 2
  • 3
  • 12
  • 1
    The problem is not your `.htaccess` or PHP code exactly. But rather your CSS calls are going to your relative paths instead of the root. – Giacomo1968 Jul 07 '14 at 03:31
  • 1
    To add to what @JakeGould said, use `base_url()` in your template files that link to the CSS to dynamically get the full URL. – Alexander O'Mara Jul 07 '14 at 03:33
  • 1
    @AlexanderO'Mara I usually post an answer about the proper use of base paths & absolute paths, but the code here does not really explain where this would be coming from so unclear how to truly advise that here. Here is the last answer I posted on the topic. Maybe it will help: http://stackoverflow.com/questions/24463536/base-url-in-php/24463585#24463585 – Giacomo1968 Jul 07 '14 at 03:39

0 Answers0