httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas CarriƩ <>
Subject [users@httpd] redirect based on HTTP_HOST using mod_rewrite
Date Wed, 25 Jan 2012 21:58:02 GMT

I have 2 DNS entries

They target the same IP:

I want to setup apache
- to accept requests on
- to forbid requests on

I have tried this config

    # page to be served for users that try to access
    # instead of
    Alias /unauthorized /var/www/unauthorized.txt
    RewriteEngine On
    RewriteCond %{HTTP_HOST}
    RewriteCond %{QUERY_STRING} !unauthorized
    RewriteRule ^/(.*)$ /unauthorized

It is the first time I use module mod_rewrite is totally new to me, 2 things 
are unclear to me:

- how to do a logical AND condition :
      HTTP_HOST is
      and QUERY_STRING is not /unauthorized

- what kind of option to add to RewriteRule to avoid infinite recursion


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message