Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have this image link that works on remote server but doesn't work on local server.

 //Remote Server Works

        <img src="../behind_wwwroot/img_folder_fast/cars.jpg">

//Local Server doesn't work

    <img src="../behind_wwwroot/img_folder_fast/cars.jpg">

Local server dir tree

www/my_server

Apache Document root and Directory set to C:/wamp/www/my_server

Image files exist in C:/wamp/www/behind_wwwroot/img_folder_fast/cars.jpg

I want to put uploaded images behind www root for obvious reasons.

Anybody pls help

share|improve this question
    
what are the permissions of 'behind_wwwroot' on the local machine? –  DTest Jul 29 '11 at 19:57
    
what are the permissions on the file? 9 secs faster @DTest, nice. Linux command: ls -ltr behind_wwwroot behind_wwwroot/img_folder_fast behind_wwwroot/img_folder_fast/cars.jpg –  Phill Pafford Jul 29 '11 at 19:57
    
The folder has Read/write/Execute permissions alright. –  Frank Nwoko Jul 29 '11 at 20:22
add comment

migrated from stackoverflow.com Aug 1 '11 at 2:11

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 1 down vote accepted

There must be something else going on.

The web browser with translate the relative URL into an absolute one and then request it. As such you cannot access files outside the www root.

A webpage on example.com:

<img src="../folder/file.jpg" />

Will translate to a request for:

http://example.com/folder/file.jpg

More specifically. You cannot request a file outside of the example.com www root. If however your web page was in a folder (e.g. example.com/mywebsite/) then this could work.

What reasons do you have for having the images outside of the www root? If you think you can access them anyway what advantage does it have? If you MUST have them outside the www root you need to have the server redirect requests using either PHP or some .htaccess rules.

share|improve this answer
    
Ok. Thanks. This is so a hacker can not gain access and delete all user uploaded images. –  Frank Nwoko Jul 30 '11 at 23:51
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.