1

Just to give a little background: I'm using Dreamweaver CS5 for coding php, XAMPP apache as a test server, and 000WebHost.com for free hosting for testing on a remote server.

I coded an application with a login form that requests images and stores them above webroot along with a few other secure files. All of the program works 100% perfectly on apache as my test server on my laptop. The second I copied the files to my remote server, any links attempting to access outside webroot are broken. I can get to my login page and a simple processing script that is under webroot, but not past it.

Why are my links suddenly broken? I triple checked that all of the relative paths are correct, using a file structure such as:

  • Includes
  • Images
  • Secure
  • public_html

from public_html, I used the file path: $path = '../Secure/test1.php';

Thanks for any help, I really need to finish this soon.

DMor
  • 770
  • 2
  • 8
  • 17
  • What happens instead? Do you get any error messages? – Gumbo Jun 17 '12 at 19:10
  • I apologize, i knew i forgot something, it sends me to 000WebHost's error page: http://error404.000webhost.com/? – DMor Jun 17 '12 at 19:12
  • 1
    I'm pretty sure 000WebHost.com free hosting wont allow you to access above the webroot – Musa Jun 17 '12 at 19:12
  • Contact the hosting provider. You pay for their support and they should know their PHP settings betetr than anybody. – Emil Vikström Jun 17 '12 at 19:12
  • This is just a test server, I will be using network solution as a host for the final product, so is this just 000WebHost not giving me permission? – DMor Jun 17 '12 at 19:14

3 Answers3

1

As said Musa, you shouldn't be able to access anything outside you "public_html" directory. Instead, you should put all the other directories in it, and change (if needed) relative paths of the links so that they work wit ha structure like this:

public_html
|
|_Includes
|
|_Images
|
|_Secure

EDIT: As said in my comment to this answer, i'm referring to the hosting company you are using, not to each and every hoster out there. It's a free one, not everything is as we want it :)

Erenor Paz
  • 3,061
  • 4
  • 37
  • 44
  • http://stackoverflow.com/questions/3034474/storing-script-files-outside-web-root It's common practice to put sensitive files outside of webroot. I have the include files outside of Webroot because they hold sensitive information about the login form, I keep the Images outside of webroot so no one can type a direct path in a URL to access them directly, Same with the secure pages. Its a common practice, I just need to know how to implement it properly – DMor Jun 18 '12 at 08:39
  • Maybe i've been not so clear in my comment, sorry. I meant that with webhost you shouldn't have antyhing outside you "public_html" folder, as you can see in the file manager, where there is a "DO_NOT_UPLOAD_HERE" file. I've taken a screenshot of a site i made on that web hoster: http://erenor.net/immagini_hostate/webhost_image.png – Erenor Paz Jun 18 '12 at 13:42
  • You're correct, and I guess I deleted that file. Thank you for the help. – DMor Jul 02 '12 at 07:04
1

If I'm not mistaken, you are trying to load images, stored in a private directory, directly onto you homepage. Issue is that visitors cannot access the private directory. Any path included in your page will result in a 404. On your local computer, you webserver might have served you images or links which are available to you because you are the computer locally; your OS does not check whether you are a webserver and should be able to see the files.

Either you should store the files, which should be accessible, publicly in a public folder or you should create some sort of proxy method, eg with PHP to check what file is requested and load it from disk and show.

Luceos
  • 6,629
  • 1
  • 35
  • 65
0

Check the error logs if available, they are usually your best source of information when you run into errors and don't get an error message. One possible problem could be your file permissions - make sure the Secure directory and everything inside it is readable by the web server.

Kaivosukeltaja
  • 15,541
  • 4
  • 40
  • 70
  • Looking for error logs in the cpanel, but can't find them. How do i check file permissions? – DMor Jun 17 '12 at 19:18
  • @user1386498: I'm guessing you don't have shell (SSH) access? I don't know about this hosting provider's control panel's features, but they might be included in file listings. They should look something like `-rwxr-xr-x`. – Kaivosukeltaja Jun 17 '12 at 19:31
  • However, if this is not your final deployment server, I'd say you shouldn't bother trying to get it working as the actual production server will most likely be a completely different and less limited environment. – Kaivosukeltaja Jun 17 '12 at 19:33