Hi

I need to configure my Apache web server to redirect an incoming request if 
it¹s not from a specific web site.  I¹ve been trying unsuccessfully to use the 
HTTP_REFERER to do this.   Most of the discussion I¹ve found about this 
involves the prevention of hotlinking.  My webserver a RHEL5 box running RHEL5 
Apache 2.2.3.

This is what I want to do:
        Request from www.foo.com<http://www.foo.com> goes to the web site.
        Request from anyone else gets an html page that essentially says you 
have to be registered to access the web site.

Here is the original VirtualHost definition:

<VirtualHost *:80>
    RewriteEngine on
    RewriteRule   ^/$  /training/who/cgi-bin/login [R]

    ServerName example.org

    DocumentRoot /apps/example/training/www/Root/who

    ScriptAlias /training/who/cgi-bin/ 
"/apps/example/training/www/Root/who/cgi-bin/"
    ScriptAlias /training/cgi-bin/     
"/apps/example/training/www/Root/who/cgi-bin/"
    Alias       /training              "/apps/example/training/www/Root"
    <Directory "/apps/example/training/www/">
       AllowOverride All
       Options +FollowSymlinks +Indexes
       Order allow,deny
       Allow from all
    </Directory>
</VirtualHost>


Here is one example of the syntax I¹ve tried. This displays the Apache default 
web page.  The error message in the log file is Directory index forbidden by 
Options directive.
<VirtualHost *:80>
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://www.foo.com [NC]
    RewriteRule ^(.*)$ http://example.org/training/who/redirect.html [L]

    RewriteCond %{HTTP_REFERER} http://www.foo.com [NC]
    RewriteRule   ^/$  /training/who/cgi-bin/login [R]



This next syntax results in getting to the application login page instead of 
getting the redirect.html page displayed.

<VirtualHost *:80>
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} .
    RewriteCond %{HTTP_REFERER} !.*www.foo.com [NC]
    RewriteRule ^(.*)$ http://example.org/training/who/redirect.html

    RewriteCond %{HTTP_REFERER} .
    RewriteCond %{HTTP_REFERER} http://www.foo.com [NC]
    RewriteRule   ^/$  /training/who/cgi-bin/login [R]


This also skips the redirect, and goes to the login page, without graphics:



<VirtualHost *:80>

    RewriteEngine on



    RewriteCond %{HTTP_REFERER} !^$

    RewriteCond %{HTTP_REFERER} !^http://www\.foo\.com/.*$ [NC]

    RewriteRule \.*$ http://example.org/training/who/redirect.html [R=301,L]



    RewriteRule   ^/$  /training/who/cgi-bin/login [R]



Any help is appreciated.

Thank you.


Cathy

---
Cathy L. Smith
IT Engineer

Pacific Northwest National Laboratory
Operated by Battelle for the
U.S. Department of Energy

Phone:      509.375.2687
Fax:        509.375.2330
Email:      [email protected]



_______________________________________________
PLUG mailing list
[email protected]
http://lists.pdxlinux.org/mailman/listinfo/plug

Reply via email to