Path to files

Asked by:
MichaelB / 34 Points
Time:
2012-07-26 2:07 am EST
Category:
Website Troubleshooting
Hits:
491
I'm building a site and coded the path to the css as such:
/styles/site.css
I've created the 'styles' folder right under the 'public_html' folder. However it came up 404. If I change the path to styles/site.css, then it worked. Why is the absolute path not working? Did I create the 'style's folder in the wrong location?

To ask this user for more information, please first login.

To submit an answer, please login.

Best answer chosen by User

0

ScottM
Staff
8,823 Points
2012-07-26 8:26 am EST
Hello MichaelB,

Both are actually relative paths. An example of an absolute path would be http://www.domain.com/styles/site.css, so no matter what server or folder it is called from, it knows where to go. The issue is a temporary one as it lies in a discrepancy of where the root lies for the Temp URL vs the actual domain, once it is pointed to us.

Using a forward slash at the beginning of a relative path with Linux means to begin at the root of the domain name being used. With a Temp URL, the root is the folder just above the public_html folder at /home/username. The root of the domain name is the public_html folder itself at /home/username/public_html. Since the preceding slash tells the temp URL to start at root, it cannot find the sites folder since it is looking one level higher.

You can use either one (/styles/site.css or styles/site.css) with the domain name itself, it will behave correctly. For testing with the temp URL, simply leave off the first slash. Most people simply choose to forego the first slash altogether to avoid the issue with a temp URL.

Best Regards,
Scott M

To submit a comment on this answer, please first login.

Want to share this Question?

News / Announcements

Update to SSL Certificates - Certificate Warnings
1969-12-31 11:00 am EST
Hits: 680

Related Articles

It looks like there are no related articles.
Would you like to ask a question about this page? If so, click the button below!

Help Center Search

Current Customers

Email: support@WebHostingHub.com Ticket: Submit a Support Ticket
Call: 877-595-4HUB (4482)
757-416-6627 (Intl.)
Chat: Click To Chat Now

Ask the Community

Get help with your questions from our community of like-minded hosting users and Web Hosting Hub Staff.

Not a Customer?

Get web hosting from a company that is here to help.