Re: redirect based on HTTP_HOST using mod_rewrite

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

 



On Wednesday, January 25, 2012 11:03:50 PM Serge Fonville wrote:
> Hi,
> 
> RewriteCond does an AND unless you tell it to do an OR.

OK for the AND condition

> 
> You mention the querystring, but /unauthorized isn't it, is it?
> if you want to filter based on the urlpath you should do it differently.
>
> Please add the information so we better understand what you are trying to
> accomplish.

the goal is that the only valid page for b.domain.com is /unauthorized
so the logic I want to do is

     HTTP_HOST is b.domain.com
     and url path is not /unauthorized
     then display page /unauthorized

Currently I have this

    RewriteCond %{HTTP_HOST}  =b.domain.com
    RewriteCond %{REQUEST_URI} !^.*unauthorized.*$
    RewriteRule ^/(.*)$ /unauthorized

I am getting closer, I have replaced QUERY_STRING by REQUEST_URI but it is 
still not ok : requests to b.domain.com do not display the unauthorized 
message but produce a connection reset and request to a.domain.col does not 
respond

> 
> 
> 
> HTH
> 
> Kind regards/met vriendelijke groet,
> 
> Serge Fonville
> 
> http://www.sergefonville.nl
> 
> Convince Google!!
> They need to add GAL support on Android (star to agree)
> http://code.google.com/p/android/issues/detail?id=4602
> 
> 
> 2012/1/25 Thomas Carrié <thocar@xxxxxxx>
> 
> > 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

---------------------------------------------------------------------
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