CSS and GoDaddy
Posted: Mon Mar 16, 2009 1:40 am
Hi, when I try referencing a css file outside the current directory such as the styles are not loaded. Any thoughts?
Code: Select all
src="../css/styles.css"A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
src="../css/styles.css"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.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?
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.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?
Do you know what I would need to do to make it work?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.
So I would have to go back and change all of them when I post it online?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.
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.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.