Path to files

Asked by:
MichaelB
Time:
2012-07-26 6:07 am
Category:
Website Troubleshooting
Hits:
239
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?

You must login before you can ask a follow up question.

You must login before you can submit an answer.

Best answer chosen by User

0

ScottM
2012-07-26 12:26 pm
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

You must login before you can post a comment about this answer.

Like this Question?

Have a Question?

If you need some help, submit your question to our Community! We guarantee a response within 60 minutes (8am - 9pm EST, Monday - Friday)

Recent Questions

  1. "WordPress Login Temporarily Disabled"?
  2. Google Adwords Credit Link Doesn't Work in AMP
  3. my email is being rejected

Support 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.