redirect based on HTTP_HOST using mod_rewrite

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux