Page 1 of 1

Freehostia directory problem.

Posted: Sun Nov 18, 2007 11:54 am
by JellyFish
Hey, I got this free account with freehosia.com and I'm currently building an iphone game. :P

If you go to my game, BlackOut, and look at the css file located '/lib/css/main.css' you'd see several background properties but none of which are applied to the selected elements, at least not the way I intend them to be.

At the moment of writing, I have all my background URI as so: '/images/image-name.png'.

When I look at what file i returned it's "http://bookmarklets.freehostia.com/imag ... e-name.png", but sense my game and all it's contents are located in the directory "/blackout/", I'd assume it to be "http://bookmarklets.freehostia.com/blac ... e-name.png".

So I figured if I added a base element to my head with the attribute href="http://bookmarklets.freehostia.com/blackout/" that it would solve the problem. It didn't, unfortunately.

So I tried getting rid of the first '/' in my background URLs; "/images/image-name.png" to "images/image-name.png". and what that does is returns "http://bookmarklets.freehostia.com/blac ... e-name.png".

Whew... I've ran out of bullets, what should I try next?

So, It has to be my server, duh, no other hosting service acts up like this. I could easily write absolute paths but that wouldn't really be intuitive on the my coding habits; I'd rather get my hosting straighted out, or at least find out the what's causing these issues.


Anyone got any ideas? :roll: I'd so much appreciate them.

Thanks for reading.

Posted: Sun Nov 18, 2007 11:58 am
by feyd
Uhm... /blackout/images/…

Posted: Sun Nov 18, 2007 12:53 pm
by JellyFish
feyd wrote:Uhm... /blackout/images/…
Oh yes! That would also work along with http://bookmarklets.freehostia.com/blackout/images/... Thanks for pointing that out.

But what I'd really like to know is why my hosting server would do what it's doing? Do you know of any apache configuration or something that effects how directories are handled and could it be done with an .htaccess file?

Posted: Sun Nov 18, 2007 1:23 pm
by feyd
If I remember correctly, the base element isn't supposed to affect the CSS as it's a separate document with its own model.

Posted: Sun Nov 18, 2007 2:29 pm
by JellyFish
feyd wrote:If I remember correctly, the base element isn't supposed to affect the CSS as it's a separate document with its own model.
Alright that's good to know. But why would css be acting like this on this server? I don't suppose it acts like this else where?

Posted: Sun Nov 18, 2007 3:02 pm
by RobertGonzalez
I think you are getting lost in your pathing. The app is at http://bookmarklets.freehostia.com/blackout/ so your server path to your index page will be something like /home/username/public_html/blackout. Since your main.css CSS file is located at lib/css/ you're path to that on the server is something like /home/username/public_html/blackout/lib/css.

Since you are referencing your images like "/images/background.png" you are telling the browser CSS renderer to look in the root directory for a directory named images. Since it is not in the root, but in the "blackout" directory, it is not finding the image. You can fix this in one of two ways: either fix the path in your CSS file to to "/blackout/images/imagename.png" or use relative paths in the CSS file, like "../../images/imagename.png". Either will work and both are the correct way to path your images for CSS rendering.

Posted: Mon Nov 19, 2007 2:27 pm
by JellyFish
Everah wrote:I think you are getting lost in your pathing. The app is at http://bookmarklets.freehostia.com/blackout/ so your server path to your index page will be something like /home/username/public_html/blackout. Since your main.css CSS file is located at lib/css/ you're path to that on the server is something like /home/username/public_html/blackout/lib/css.

Since you are referencing your images like "/images/background.png" you are telling the browser CSS renderer to look in the root directory for a directory named images. Since it is not in the root, but in the "blackout" directory, it is not finding the image. You can fix this in one of two ways: either fix the path in your CSS file to to "/blackout/images/imagename.png" or use relative paths in the CSS file, like "../../images/imagename.png". Either will work and both are the correct way to path your images for CSS rendering.
I understand, but why is it that godaddy's shared servers act differently? If a css file is in a the directory /lib/styles/main.css and the html or php file included the css file is in the root directory then the css file would inherit the root directory, if you that makes sense.

EDIT: Maybe it doesn't maybe I just never noticed. I think I figured it out.

Posted: Mon Nov 19, 2007 6:07 pm
by RobertGonzalez
You might want to check to make sure that is how things were working. Pathing is pretty straight forward, albeit frustrating at times.