CodeIgniter Forums

Full Version: site works on locahost, but not on web host
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]tokyotech[/eluser]
I am using
Code:
link_tag('style/master.css')

to include my CSS file. It shows the correct path in the source on my localhost:
Quote:http://localhost/appName/system/application/style/master.css

When I uploaded my entire site to http://www.site.com, my CSS include path became incorrect:
Quote:http://www.site.com/style/master.css

It seems to have dropped half of the path, so I no longer see styles applied. What do I need to configure to fix this?

El Forum

[eluser]Eric Barnes[/eluser]
I would say check your base_url in config.php.

Also why are you storing a style sheet in system/application/style? To me this should be in the views or in its own directory like your incorrect link.

El Forum

[eluser]tokyotech[/eluser]
[quote author="suzkaw" date="1248941916"]I would say check your base_url in config.php.[/quote]

What should it be changed to? Why is this value changing on the fly from localhost to webhost?

Quote:Also why are you storing a style sheet in system/application/style? To me this should be in the views or in its own directory like your incorrect link.

Because that's where all other files (controllers, views) specific to this application are stored.

El Forum

[eluser]bretticus[/eluser]
[quote author="tokyotech" date="1248946584"]
Because that's where all other files (controllers, views) specific to this application are stored.[/quote]

Do you have more than one application folder for your one URL? Are you toggling different app folders in index.php or have you written some dynamic way to change applications inside index.php? If not, putting media files in your applications folders is a dead giveaway you are using CI and PHP. The standard practice is to put your media files outside your system folders so that they are relative to your virtual root. Mostly because the recommended apache rewrite (in your .htaccess file and assuming you are using it) blocks direct access to your system folder (a pretty good idea actually.) The following is a typical setup for folder structure in CI:

|-- media
| -- css
| |-- master.css
|-- system

Using that, your view files you can simply reference
Code:
link_tag('media/css/master.css')
and your path should be relative to your base_url in config.php (as was previously mentioned.)

Note, you could also setup your directories like:

|-- style
| |-- master.css
|-- system

To use your existing code:
Code:
link_tag('style/master.css')

El Forum

[eluser]Unknown[/eluser]
Thanks Ed for the uplifting comment. It is good to know that somehow I could be of help although the thread is way old.
voiture simulation de credit immobilier en ligne - Simulation credit immobilier en ligne. L’Internet a rendu encore plus facile d’obtenir de l’aide pour trouver le credit immobilier.

El Forum

[eluser]tokyotech[/eluser]
I will try that, Bretticus.

May I ask what is the point of hiding the fact that I'm using CodeIgniter? If someone knows my directory structure, how can they hack my site? I'm going to be using CI's XSS, SQL Injection, and whatnot prevention. Is that enough?

I am not speaking in an antagonizing tone. I am just trying to learn.

El Forum

[eluser]bretticus[/eluser]
Well, it's the old security by obscurity argument. but imagine that a security vulnerability is found in codeigniter code. It's easy at that point for a bot to search the web for paths with index.php/controller/action or system/application/...

I like blocking access to system via apache rewrite personally because I have seen IT administrators inadvertently kill PHP parsing leaving the source code open to prying eyes. Under this scenario, any encryption keys or database passwords are open to public view because a CI has great documentation. Smile In this case...

Code:
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

...won't help because PHP cannot be parsed.

If apache blocks access to the system folder (assuming they didn't hose the rewrite module at the same time) then your source code is safe.

Finally, it's just better form since the system folder is essentially a server-side library never meant to be "Seen" by the client browser.