You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Darren Ward (darrward)" <da...@cisco.com> on 2014/03/02 13:09:59 UTC

RE: [users@httpd] Mixing ReWrite and AliasMatch

Thanks Igor

So in my example if I see a UserAgent starting with CaptiveNetworkSupport then I should rewrite the URL to http://originalhost/library/test/success.html

THEN the AliasMatch ending in /success.html should then map the request to the local file

Is that correct?

If so doesn't seem to be working as I can see UserAgent matching the RewriteCond in the logfile:

wifi-tc:192.168.104.39 - - [28/Feb/2014:11:02:42 +1100] "GET /ah66Mlma/GwaqQ1ka.html HTTP/1.0" 200 334 "-" "CaptiveNetworkSupport-277 wispr"
wifi-tc:192.168.104.39 - - [28/Feb/2014:11:15:08 +1100] "GET /NLHHvH2Y/Z4CXHCDW/Q9VhrIWd/x3O3upE2.html HTTP/1.0" 200 334 "-" "CaptiveNetworkSupport-277 wispr"

I added:

    RewriteLog logs/wifi-tc-rewrite

But it's always a zero length file with no hits (restarted Apache of course)

What's the best method to test a ReWrite and check debugs or logs?

Darren

--------------------------------------------------------------------------  

From: Igor Cicimov [mailto:icicimov@gmail.com] 
Sent: Friday, 28 February 2014 6:55 PM
To: users
Subject: Re: [users@httpd] Mixing ReWrite and AliasMatch


On 27/02/2014 12:23 PM, "Darren Ward (darrward)" <da...@cisco.com> wrote:
>
> I then thought about putting the Rewrite at the bottom but when an AliasMatch is met it doesn't continue searching I don't think so it would hit the rewrite because of the last AliasMatch statement
>
Rewrite rewrites the url's and Alias maps url's to the file system. Hence apache will execute mod_rewrite before mod_alias no matter of the statement order.
> <VirtualHost 10.67.21.131>
>     DocumentRoot   /www/docs/wifi-tc
>
>     RewriteEngine   on
>     RewriteCond      %{HTTP_USER_AGENT}     ^CaptiveNetworkSupport*
>     RewriteRule      ^(.*)$      /library/test/success.html [L]
>
>     ScriptAlias        /cgi-bin/ "/www/docs/wifi-tc/cgi-bin/"
>
>     AliasMatch      /perl/(.*)$     /var/www/perl/$1
>     AliasMatch     /success.html$     /www/docs/wifi-tc/library/test/success.html
>     AliasMatch     ^(.*)$      /www/docs/wifi-tc/index.html
>
> </VirtualHost>
>
>
> Looking for some advise on how to rewrite this so that it would not change the captive portal detect rewrite
>
> Darren
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Mixing ReWrite and AliasMatch

Posted by "Darren Ward (darrward)" <da...@cisco.com>.
I thought the * was required to continue regex matching a longer UserAgent field - if not then maybe that's the problem

i.e. ^Captive   !=   CaptiveNetworkSupport-277 wispr

The entries are definitely in the right vhost but I'll be running some more testing later this afternoon and will advise how I go

Darren

-----Original Message-----
From: Eric Covener [mailto:covener@gmail.com] 
Sent: Monday, 3 March 2014 10:05 AM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Mixing ReWrite and AliasMatch

On Sun, Mar 2, 2014 at 3:27 PM, Darren Ward (darrward) <da...@cisco.com> wrote:
> Thanks
>
> Still can't get this string to be matched though
>
>     RewriteCond %{HTTP_USER_AGENT} ^CaptiveNetworkSupport*
>     RewriteRule ^(.*)$ /library/test/success.html [PT]
>
> Isn't matching:
>
> wifi-tc:192.168.104.39 - - [28/Feb/2014:11:02:42 +1100] "GET /ah66Mlma/GwaqQ1ka.html HTTP/1.0" 200 334 "-" "CaptiveNetworkSupport-277 wispr"
> wifi-tc:192.168.104.39 - - [28/Feb/2014:11:15:08 +1100] "GET /NLHHvH2Y/Z4CXHCDW/Q9VhrIWd/x3O3upE2.html HTTP/1.0" 200 334 "-" "CaptiveNetworkSupport-277 wispr"
>
> Logic seems ok and the regex is a simple one...

The trailing * is probably unintended.  Likely your rewrite is in the wrong vhost / unused htaccess if it appears to never match AND you can't get trace.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Mixing ReWrite and AliasMatch

Posted by Eric Covener <co...@gmail.com>.
On Sun, Mar 2, 2014 at 3:27 PM, Darren Ward (darrward)
<da...@cisco.com> wrote:
> Thanks
>
> Still can't get this string to be matched though
>
>     RewriteCond %{HTTP_USER_AGENT} ^CaptiveNetworkSupport*
>     RewriteRule ^(.*)$ /library/test/success.html [PT]
>
> Isn't matching:
>
> wifi-tc:192.168.104.39 - - [28/Feb/2014:11:02:42 +1100] "GET /ah66Mlma/GwaqQ1ka.html HTTP/1.0" 200 334 "-" "CaptiveNetworkSupport-277 wispr"
> wifi-tc:192.168.104.39 - - [28/Feb/2014:11:15:08 +1100] "GET /NLHHvH2Y/Z4CXHCDW/Q9VhrIWd/x3O3upE2.html HTTP/1.0" 200 334 "-" "CaptiveNetworkSupport-277 wispr"
>
> Logic seems ok and the regex is a simple one...

The trailing * is probably unintended.  Likely your rewrite is in the
wrong vhost / unused htaccess if it appears to never match AND you
can't get trace.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] Mixing ReWrite and AliasMatch

Posted by "Darren Ward (darrward)" <da...@cisco.com>.
Thanks

Still can't get this string to be matched though

    RewriteCond %{HTTP_USER_AGENT} ^CaptiveNetworkSupport*
    RewriteRule ^(.*)$ /library/test/success.html [PT]

Isn't matching:

wifi-tc:192.168.104.39 - - [28/Feb/2014:11:02:42 +1100] "GET /ah66Mlma/GwaqQ1ka.html HTTP/1.0" 200 334 "-" "CaptiveNetworkSupport-277 wispr"
wifi-tc:192.168.104.39 - - [28/Feb/2014:11:15:08 +1100] "GET /NLHHvH2Y/Z4CXHCDW/Q9VhrIWd/x3O3upE2.html HTTP/1.0" 200 334 "-" "CaptiveNetworkSupport-277 wispr"

Logic seems ok and the regex is a simple one...

Darren

-----Original Message-----
From: Eric Covener [mailto:covener@gmail.com] 
Sent: Sunday, 2 March 2014 11:23 PM
To: users@httpd.apache.org
Subject: Re: [users@httpd] Mixing ReWrite and AliasMatch

On Sun, Mar 2, 2014 at 7:09 AM, Darren Ward (darrward) <da...@cisco.com> wrote:
> Thanks Igor
>
> So in my example if I see a UserAgent starting with 
> CaptiveNetworkSupport then I should rewrite the URL to 
> http://originalhost/library/test/success.html
>
> THEN the AliasMatch ending in /success.html should then map the 
> request to the local file
>
> Is that correct?

You'll need the [PT] flag if you want the Alias to be based off of your rewrite.

>
> If so doesn't seem to be working as I can see UserAgent matching the RewriteCond in the logfile:
>
> wifi-tc:192.168.104.39 - - [28/Feb/2014:11:02:42 +1100] "GET /ah66Mlma/GwaqQ1ka.html HTTP/1.0" 200 334 "-" "CaptiveNetworkSupport-277 wispr"
> wifi-tc:192.168.104.39 - - [28/Feb/2014:11:15:08 +1100] "GET /NLHHvH2Y/Z4CXHCDW/Q9VhrIWd/x3O3upE2.html HTTP/1.0" 200 334 "-" "CaptiveNetworkSupport-277 wispr"
>
> I added:
>
>     RewriteLog logs/wifi-tc-rewrite
>

> But it's always a zero length file with no hits (restarted Apache of 
> course)

RewriteLogLevel 9? And make sure they're set in the vhost handling the request.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Mixing ReWrite and AliasMatch

Posted by Eric Covener <co...@gmail.com>.
On Sun, Mar 2, 2014 at 7:09 AM, Darren Ward (darrward)
<da...@cisco.com> wrote:
> Thanks Igor
>
> So in my example if I see a UserAgent starting with CaptiveNetworkSupport then I should rewrite the URL to http://originalhost/library/test/success.html
>
> THEN the AliasMatch ending in /success.html should then map the request to the local file
>
> Is that correct?

You'll need the [PT] flag if you want the Alias to be based off of your rewrite.

>
> If so doesn't seem to be working as I can see UserAgent matching the RewriteCond in the logfile:
>
> wifi-tc:192.168.104.39 - - [28/Feb/2014:11:02:42 +1100] "GET /ah66Mlma/GwaqQ1ka.html HTTP/1.0" 200 334 "-" "CaptiveNetworkSupport-277 wispr"
> wifi-tc:192.168.104.39 - - [28/Feb/2014:11:15:08 +1100] "GET /NLHHvH2Y/Z4CXHCDW/Q9VhrIWd/x3O3upE2.html HTTP/1.0" 200 334 "-" "CaptiveNetworkSupport-277 wispr"
>
> I added:
>
>     RewriteLog logs/wifi-tc-rewrite
>

> But it's always a zero length file with no hits (restarted Apache of course)

RewriteLogLevel 9? And make sure they're set in the vhost handling the request.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org