Search code examples
phproutescodeigniter-url

Codeigniter Custom Routing showing root site background image?


Ok, so I have a project I'm working on: http://www.d2burke.com/exp/intern/

BaseURL is set to: '/exp/intern/'

.htaccess reroutes to /exp/intern/index.php

I have custom routes set up for

  1. http://www.d2burke.com/exp/intern/questions -- $route['apply'] = "internship/apply";

  2. http://www.d2burke.com/exp/intern/apply -- $route['questions'] = "internship/questions";

etc.

When you go to http://www.d2burke.com/exp/intern/internship/questions, all is well and the normal tan background shows up...

When you use one of the custom routes...you get the background image from my main site...? what is the world is going on?


Solution

  • You seem to overwrite the background by loading an extra style sheet in the body content like so

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

    The browser interprets this as a relative path to your page path.

    In the internship/questions page, this relative page translate to http://www.d2burke.com/exp/css/style.css, which doesn't exists.

    The fix would be to use an absolute path like /css/style.css

    Note: It's pretty obvious if you use Firebug and check the Net tab

    EDIT: Alternatively, open Firebug, click the arrow in the Console tab and enable "Show Network Error". That way any 404 error will appear in your console and come up as an error (great debug feature)