force a connection throught a php script

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yann.K

    #1

    force a connection throught a php script

    Hello.

    I have a directory with many files (and dir).
    In this directory, i have a inde.php file wich display all the file to
    download.
    I would like to force the users who come in this directory to download only
    from the index.php.
    I would that they cann't copy the link from the index.php page and paste it
    in the url adresse field, but that tey can only clic on the link on the
    index.php.

    I tried with the "SetEnvIf Referer" Apache Directive, but it don't run
    correctly.

    Any idea or track welcome ;-)

    Regards,
    --
    Yann.K
  • Colin McKinnon

    #2
    Re: force a connection throught a php script

    Yann.K wrote:
    [color=blue]
    > I have a directory with many files (and dir).
    > In this directory, i have a inde.php file wich display all the file to
    > download.
    > I would like to force the users who come in this directory to download
    > only from the index.php.[/color]

    Move the 'downloadable' files out of the document root (or disallow them by
    extension/path in your webserver config) and write a 'loader' php script
    which sets the mimetype and outputs the file to the browser.

    HTH

    C.

    Comment

    • Janwillem Borleffs

      #3
      Re: force a connection throught a php script

      Yann.K wrote:[color=blue]
      > I have a directory with many files (and dir).
      > In this directory, i have a inde.php file wich display all the file to
      > download.
      > I would like to force the users who come in this directory to
      > download only from the index.php.
      > I would that they cann't copy the link from the index.php page and
      > paste it in the url adresse field, but that tey can only clic on the
      > link on the index.php.
      >
      > I tried with the "SetEnvIf Referer" Apache Directive, but it don't run
      > correctly.
      >
      > Any idea or track welcome ;-)
      >[/color]

      One of the many ways to implement this, is to apply Apache's mod_rewrite
      module:

      RewriteEngine On
      RewriteCond %{REQUEST_URI} !^.*/index.php
      RewriteRule ^([^/]+)$ index.php?$1 [L]

      Requests like:
      /whatever.whatev er

      Are now directed to:
      /index.php?whate ver.whatever

      Where index.php can use the $_SERVER['QUERY_STRING'] to retrieve and pass
      through the requested file.


      JW



      Comment

      Working...