CSS and GoDaddy

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
prgmctan
Forum Newbie
Posts: 19
Joined: Mon Feb 23, 2009 11:29 am

CSS and GoDaddy

Post 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?
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: CSS and GoDaddy

Post 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?
prgmctan
Forum Newbie
Posts: 19
Joined: Mon Feb 23, 2009 11:29 am

Re: CSS and GoDaddy

Post 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
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: CSS and GoDaddy

Post 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?
prgmctan
Forum Newbie
Posts: 19
Joined: Mon Feb 23, 2009 11:29 am

Re: CSS and GoDaddy

Post 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.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

Re: CSS and GoDaddy

Post 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.
prgmctan
Forum Newbie
Posts: 19
Joined: Mon Feb 23, 2009 11:29 am

Re: CSS and GoDaddy

Post 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?
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: CSS and GoDaddy

Post 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.
prgmctan
Forum Newbie
Posts: 19
Joined: Mon Feb 23, 2009 11:29 am

Re: CSS and GoDaddy

Post 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?
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: CSS and GoDaddy

Post 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.
prgmctan
Forum Newbie
Posts: 19
Joined: Mon Feb 23, 2009 11:29 am

Re: CSS and GoDaddy

Post 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.
User avatar
omniuni
Forum Regular
Posts: 738
Joined: Tue Jul 15, 2008 10:50 pm
Location: Carolina, USA

Re: CSS and GoDaddy

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