Freehostia directory problem.

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Freehostia directory problem.

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Uhm... /blackout/images/…
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post 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?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
User avatar
JellyFish
DevNet Resident
Posts: 1361
Joined: Tue Feb 14, 2006 7:18 pm
Location: San Diego, CA

Post 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.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post 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.
Post Reply