Advanced Search

Results 1 to 7 of 7

Thread: uploading web file outside doc-root not working

  1. #1
    Join Date
    Aug 2013
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default uploading web file outside doc-root not working

    I uploaded my file oustside the root directory while leaving
    only index.php in the public_html

    here is my directory structure


    /home/user
    /myweb_application ----> my uploaded files
    /access_log
    /etc
    /mail
    /public_htm
    /public_ftp
    /tmp
    /www

    Here is how i configured it

    1: inside /public_html I have index.php with the content as follow
    PHP Code:
    <?php
    require '../myweb_application/web_index.php';
    ?>
    2: Inside /myweb_application i created 2 files for testing along with web_index.php making it 3 php files

    web_index.php

    HTML Code:
    <html><body>
    
            <li> <a href="test1.php">Connect test1</a><br><br>
     </li>
            
       <li> <a href="test2.php">Connect test2</a><br><br>
     </li>   
    
    
          </ul>
    </body></html>

    test1.php
    HTML Code:
    <html>
    I am test 1
    </html>
    test2.php

    HTML Code:
    <html>
    I am test 2
    </html>


    Finally, the directory becomes

    /home/user
    /myweb_application ----> my uploaded files
    web_index.php
    test1.php
    test2.php

    /access_log
    /etc
    /mail
    /public_htm
    index.php

    /public_ftp
    /tmp
    /www



    when i load the page as http://example.com
    index.php loads web_index.php from outside the root


    Look at my problem now

    when i click on link CONNECT TEST1 of test1.php from web_index.php it says


    The requested URL /test1.php was not found on this server.

    Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.


    what could be the problem. Is it because test1.php and test2.php is outside the public_html what about web_index. php that is working. Can someone help to fix that

    thank you
    Last edited by keyboard; 10-05-2013 at 11:44 PM. Reason: Format: Html [html][/html], Php [php][/php]

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,886
    Thanks
    16
    Thanked 288 Times in 287 Posts
    Blog Entries
    4

    Default

    The public_html folder is where you should put all the files/pages associated with your primary domain - I'm not sure why you're creating folders above this. Folders above the public_html directory are usually part of the default server/account setup and are placed outside the public domain for security reasons. That is why you cannot access the pages you've put in the "../myweb_application/" folder in a browser. If you want the pages/other resources to be accessed over the Internet, you should move them all to the public_html folder (or a sub-folder within)
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  3. #3
    Join Date
    Aug 2013
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you so much Berverleyh. I have been reasoning that thing. My brain was just crashing. You see there is a lot of confusion on the internet. This programmer will say this, the other will that thereby creating confusion here and there. You have cleared me now.

    I will also like if you could comment on this for setting of file/directory permission
    the default settings is as followss
    /home/user

    /access_log = 750
    /etc = 750
    /mail = 750
    /public_htm =750
    /public_ftp =750
    /tmp = 750
    /www =755

    some programmers suggest setting all the permission to be accessible by only the user as 600
    some says 640
    some says 700

    what can you suggest that will be the best way to set the permission on each.

    Thank You

  4. #4
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,886
    Thanks
    16
    Thanked 288 Times in 287 Posts
    Blog Entries
    4

    Default

    Sadly I am not a server administrator - I'm a website technician by profession - so I mainly leave the server permissions to my server-trained colleagues, or as the web host sets them, depending on whether I'm in my day-time job or working on freelance projects in my spare time. I work mainly on Windows during the day (where it is not my role to change folder permissions - indeed anything security related has to be authorised by the network manager) and after-hours I work on Linux where, via my hosting accounts, I cannot access any folder above the domain root, although I can say with 100% certainty there that the public folder defaults there are 755 and files are 644.

    Sorry I could not be of any more help.
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  5. #5
    Join Date
    Aug 2013
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you.

  6. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,631
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    To offer a little bit of an answer to your original question, the reason your link doesn't work is because you file structure no longer matches the structure of your links. From example.com, <a href="link1.php"> will try to load example.com/link1.php, which, in your case, corresponds to /home/user/public_html/link1.php - there's no such file there.

    If you want the request to work, you're going to have to tell the server where that file actually is (probably via mod_rewrite and/or a php "routing" script).

    In most cases, you don't actually need to do this sort of thing. It can, however, provide an extra layer of security for web applications where you need to have control over which files people access, and how. If you'd like to explain more about what you're trying to accomplish, I might have some more specific answers for you.

  7. #7
    Join Date
    Aug 2013
    Posts
    53
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    thanks

Similar Threads

  1. Uploading file for particular ID
    By rajesh.bl in forum PHP
    Replies: 1
    Last Post: 01-10-2009, 04:45 AM
  2. file uploading
    By duke_1222 in forum ASP
    Replies: 4
    Last Post: 11-24-2006, 12:11 AM
  3. uploading file????...
    By pavmoxo in forum PHP
    Replies: 4
    Last Post: 08-16-2006, 10:26 AM
  4. file uploading?
    By killabeez6666 in forum Other
    Replies: 3
    Last Post: 03-22-2006, 09:05 PM
  5. file uploading?
    By killabeez6666 in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 03-22-2006, 09:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •