Page 1 of 1

CSS and GoDaddy

Posted: Mon Mar 16, 2009 1:40 am
by prgmctan
Hi, when I try referencing a css file outside the current directory such as

Code: Select all

src="../css/styles.css"
the styles are not loaded. Any thoughts?

Re: CSS and GoDaddy

Posted: Mon Mar 16, 2009 8:50 am
by jaoudestudios
what is your directory structure?

By going up a level to the css are you still in the public/htdocs folder accessible by the url or are you a directory above?

Re: CSS and GoDaddy

Posted: Mon Mar 16, 2009 1:11 pm
by prgmctan
jaoudestudios wrote:what is your directory structure?

By going up a level to the css are you still in the public/htdocs folder accessible by the url or are you a directory above?
I have the public_html folder with a css folder and an admin folder. I have files in the admin folder that I want to apply styles to.

-admin
index.php
-css
styles.css
index.php

Re: CSS and GoDaddy

Posted: Mon Mar 16, 2009 1:37 pm
by jaoudestudios
That should be fine.

Does your code work locally? And when you upload it it does not work?

Are you testing/developing on a windows machine and are you upload to a linux server. Windows server is more forgiving than linux, linux is case sensitive and only accepts '/' in the directory structure.

What is the link to your website?

Re: CSS and GoDaddy

Posted: Mon Mar 16, 2009 1:45 pm
by prgmctan
jaoudestudios wrote:That should be fine.

Does your code work locally? And when you upload it it does not work?

Are you testing/developing on a windows machine and are you upload to a linux server. Windows server is more forgiving than linux, linux is case sensitive and only accepts '/' in the directory structure.

What is the link to your website?
Yeah, I'm testing in windows and uploading to linux. The url is lutherultimate.com. One thing is that when I access the admin area through admin.lutherultimate.com/schedule.php, it doesn't work, but if I do lutherultimate.com/admin/schedule.php it does.

Re: CSS and GoDaddy

Posted: Mon Mar 16, 2009 1:54 pm
by jaoudestudios
Ofcourse, admin.lutherultimate.com/schedule.php is a subdomain so it wont have the same path to the css file on the main domain as the admin directory under the main domain.

Re: CSS and GoDaddy

Posted: Mon Mar 16, 2009 1:55 pm
by prgmctan
jaoudestudios wrote:Ofcourse, admin.lutherultimate.com/schedule.php is a subdomain so it wont have the same path to the css file on the main domain as the admin directory under the main domain.
Do you know what I would need to do to make it work?

Re: CSS and GoDaddy

Posted: Mon Mar 16, 2009 1:59 pm
by omniuni
Remember that relative URL's are interpreted by the BROWSER, not the server. If you want to check if the file exists, try typing the path in the browsers address bar as you are telling it to use.

http://admin.example.com/admin/admin.php calling ../css/style.css would call http://admin.example.com/css/style.css

I solved this problem in my CMS by adding a setting for "BaseURL" which is prepended to links like that. That way, I just reference everything absolute when I need it to be.

Re: CSS and GoDaddy

Posted: Mon Mar 16, 2009 2:03 pm
by prgmctan
omniuni wrote:Remember that relative URL's are interpreted by the BROWSER, not the server. If you want to check if the file exists, try typing the path in the browsers address bar as you are telling it to use.

http://admin.example.com/admin/admin.php calling ../css/style.css would call http://admin.example.com/css/style.css

I solved this problem in my CMS by adding a setting for "BaseURL" which is prepended to links like that. That way, I just reference everything absolute when I need it to be.
So I would have to go back and change all of them when I post it online?

Re: CSS and GoDaddy

Posted: Mon Mar 16, 2009 2:24 pm
by omniuni
Well, the idea is that once you set the base url, it automatically is applied to all of your pages, so you don't need to re-write anything.

Re: CSS and GoDaddy

Posted: Mon Mar 16, 2009 2:30 pm
by prgmctan
omniuni wrote:Well, the idea is that once you set the base url, it automatically is applied to all of your pages, so you don't need to re-write anything.
But I'm on a testing server that doesn't have that url. I think I might have a fix by creating a styles.php page and requiring it through php.

Re: CSS and GoDaddy

Posted: Mon Mar 16, 2009 5:17 pm
by omniuni
Well, you'd set the url to http://localhost/ or whatever for you testing machine, and then http://mysite.com/ or whatever. I would definitely advise to NOT try adding style info with a require() in PHP... it's just kind of bad form!