Urgent Help Needed on Directory Permission

Discussion in 'Databases' started by Zlimp, Jan 6, 2009.

  1. #1
    hey guys!
    i want an urgent help from u guys!
    how do u restrict users from entering a specific directory (eg. www.abc.com/dir/wmv) ... i dnt want anyone to view the wmv sub folder but at the same time i want this folder to run on my site ..i.e i want it to read thru my site but i dnt want it to read if someone goes directly to tht folder..
    wht shud i do? i tried the chmod settings... if i change the permissions the folder is directly not readable (thts wht i want) but it is also not readable thru the site(obviously)
    do u guys have any solution?
    the question is a bit dumb .. i knw its easy for u guys but im not tht experienced :p ... pls give me some solution
     
    Zlimp, Jan 6, 2009 IP
  2. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #2
    If it contains php based pages then you can restrict the pages so that it only works if the referrring page is another page on your site.

    There may be other ways to do it but that is the only one I know.

    Since some browsers block the referring page and it can be faked, I am not even sure that will work.
     
    Colbyt, Jan 6, 2009 IP
  3. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Wrap it in a script outside of the wmv directory which simply reads the requested wmv file and outputs it. You can also add some permission checking logic to this script if you like. So now instead of linking to the wmv file directly, you link to the (php/asp/whatever) script.

    Then add an Apache rule (assuming you're using Apache) to that folder:
    Deny from all
    Allow from none

    so that the directory cannot be accessed via the web.
     
    phper, Jan 6, 2009 IP
  4. Zlimp

    Zlimp Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #4
    look i want it like this >> http://www.flashgamescript.com/demo/files/
     
    Zlimp, Jan 6, 2009 IP
  5. Mr_2

    Mr_2 Peon

    Messages:
    980
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    0
    #5
    create an empty text file then rename it to index.html and upload it to that directory.
     
    Mr_2, Jan 6, 2009 IP
  6. Zlimp

    Zlimp Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #6
    i did tht... thnx ... i just wanna knw... i have put tht empty index.html file on tht folder... but can anyone download a file from tht directory? u knw if someone knws the file name in tht directory ..then is it possible for him to download tht file?
    for example >>>
    http://www.flashgamescript.com/demo/games/WhackABeast.html <<< this link has an .swf file in it... and the link to tht swf file is >>> http://www.flashgamescript.com/demo/files/swf/51695.swf ... now if u see the link of the swf file gives an error msg tht this area is forbidden... so ppl cnt access the swf file directly...coz if thy get the access thy will download the swf file...
    1) my question is how can this be done?
    2) considering the solution tht u gave (empty index.html page) ... does ur solution also solves the problem of swf being downloaded by someone?
     
    Zlimp, Jan 6, 2009 IP
  7. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #7
    With Mr_2's suggestion if someone knows the file name they can still download the file directly.

    Do as what I suggested, it should work. If you're unsure about something then ask again in 'Programming' section. This has nothing to do with databases.
     
    phper, Jan 6, 2009 IP
  8. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #8
    If you are on Apache web server, then you can use .htaccess to restrict the direct access.

    Create a file ".htaccess" in demo/files and put the below content in it.

    Options +FollowSymlinks
    RewriteEngine On
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?flashgamescript\.com/ [NC]
    RewriteRule .*\.(swf)$ http://www.flashgamescript.com/ [NC]
    Code (markup):
     
    mwasif, Jan 7, 2009 IP
  9. Zlimp

    Zlimp Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #9
    ok ill post it on programming section thanks!
     
    Zlimp, Jan 7, 2009 IP
  10. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #10
    Did you try my solution?
     
    mwasif, Jan 8, 2009 IP
  11. Zlimp

    Zlimp Well-Known Member

    Messages:
    217
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    105
    #11
    thanks mwasif! i disabled it from my server... but ty so much for ur help :)
     
    Zlimp, Jan 22, 2009 IP