0

I'm aware this is similar to numerous existing posts but after looking at a number of others I wasn't able to solve my problem. I'm attempting to load a folder full of html files I've been supplied with. I didn't write them but I have been modifying them to integrate them into an existing system.

I've tried three ways of opening them, with varying success:

1) Simply right click on 'index.html' and go 'open with' and select a browser. This works perfectly!

2) Place the whole folder contents, unchanged, onto my server under 'public_html/cat/html' and navigating to the url 'localhost/cat/html/index.html'. This returns a '404 page not found error'.

3) The strange one. Place the html files in the 'application/view' folder, separate the included css and javascript files and place them in existing folders 'public_html/css' and 'public_html/js' and update the links to them in the html files appropriately. These now look something like:

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

If I load this page by running a function that uses CodeIgniter's $this->load->view(...) function it finds the index file but loads it with no css and with broken links to the other pages. I've explored the page source and seen that the link is exactly as above but clicking gives an error that reads "404 Not Found...The requested URL /css/cat/style.css was not found on this server".

I've attempted to use the base_url() function (and site_url()) like this:

<link type="text/css" href="<? base_url('css/cat/style.css') ?>" rel="stylesheet" />

and it yields the same result on the surface but examining the page source reveals the link line has become:

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

which seems to be even worse!

Any hints?

Thanks for reading

4 Answers 4

3

Try the following:

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

base_url() functon simply return value, you should take a care for displaying returned value to output! :-)

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

3 Comments

Thanks so much! Adding the 'echo' worked for the css files. I expect it works for the JavaScript too but I can't tell at the minute. Is this a good format for hyperlinks too? e.g. '<li><a href="<? echo base_url('application/views/cat/map.html') ?>">3D Map</a></li>'
Nope! That's definitely not a good way to create links, instead check URL Helper and it's anchor() function: ellislab.com/codeigniter/user-guide/helpers/url_helper.html
Any success? If yes, you can mark answer as "accepted", this may be useful for people having the same problem. ;-)
0

Have you correctly configure you config file in codeIgniter ?

Comments

0

Or shorthand

<link type="text/css" href="<?=base_url('css/cat/style.css') ?>" rel="stylesheet" />

Then view your page source and copy the link from there to your browser, see if you can access it.

Comments

0

Can try this code <link type="text/css" href="<?=base_url('css/cat/style.css');?>" rel="stylesheet" />

if it doesn't work, you could try <link type="text/css" href="<?=base_url('css/cat');?>/style.css" rel="stylesheet" />

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.