Restrict to open the documents root except the Server programs with RewriteRule

Discussion in 'Apache' started by mk1336, Oct 9, 2009.

  1. #1
    Hi,

    I want to setup the httpd.conf file to restricted direct access to the root directory( documents(PDF,power point..)). only the program that's run in that
    server could be able to open them.
    I run Apache 2.2, here is short list of httpd.conf file:

    DocumentRoot "/usr/local/apache2.2/documents"

    <Directory "/usr/local/apache2.2/documents">
    Options -Indexes +FollowSymLinks

    RewriteEngine On
    RewriteCond %{REMOTE_ADDR} !^12\.13\.5\.2$
    RewriteRule .* /myservers/fine.php?file=$2 [qsappend,L]

    AllowOverride None
    Order allow,deny
    Allow from all
    </Directory>

    with this Rewriterule I can open any files under documents directory from different IP addresses so does not redirect to the /myservers/fine.php program.

    Thanks for your help

    MK
     
    mk1336, Oct 9, 2009 IP