0

I have an index file that's store on my server under a public_html folder so it can be accessed publicly.

That address is http://example.com/randomlocation/anotherlocation/index.html

on the server that would look like public_html/randomlocation/anotherlocation/index.html

The problem however is that my css, js, and img files to display the page and run it are located on another level outside of the public html section and I'm having trouble specifying the relative or base path to get there, which would be something like:

home/site/folder/randomfolder/anotherfolder/location/styles.css

For Example:

<link rel="stylesheet"     href="http://example.com/randomfolder/another folder/assets/css/emojione.min.css"/>
 <link rel="stylesheet" href="/home/examplesite/folder/folder/folder/folder/assets/css/styles.css" /> 

Doesn't seem to work. I've tried all variations of "/" relative paths and can't figure out what I'm missing to be able to pull those files.

Robert Ettinger
  • 319
  • 1
  • 3
  • 17

2 Answers2

3

Generally when a server has a public_html folder, the server is configured so that only files inside that folder will be accessible publicly via the web. (This way, you can have things like server configs and private files outside of public_html and people won't be able to get to them by just putting the url in their browser.)

In other words, you should move your css/js/images into public_html. You can put them in subdirectories to stay organized, but they should all be under public_html somewhere.

jack
  • 2,894
  • 1
  • 13
  • 23
  • Thank you, makes sense along the lines of what I was reading and its all connected now. Will move them and look for a different solution on some of the reasons behind it and speak with the admins. – Robert Ettinger Oct 18 '16 at 14:38
1

That is purposely not allowed as it would pose a huge security problem on the server. Take a look at this SO question for a possible work around.

php link to image file outside default web directory

Community
  • 1
  • 1
TheValyreanGroup
  • 3,554
  • 2
  • 12
  • 30