httpd-users mailing list archives

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

I have 2 DNS entries
- a.domain.com
- b.domain.com

They target the same IP: 1.2.3.4

I want to setup apache
- to accept requests on a.domain.com
- to forbid requests on b.mydomain.com

I have tried this config

Listen 1.2.3.4:80
<VirtualHost 1.2.3.4:80>
    ServerName a.domain.com
    # page to be served for users that try to access b.domain.com
    # instead of a.domain.com
    Alias /unauthorized /var/www/unauthorized.txt
    
    RewriteEngine On
    RewriteCond %{HTTP_HOST}  =b.domain.com
    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 b.domain.com
      and QUERY_STRING is not /unauthorized

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

Thomas

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message