Re: Cat request + query for rewrite?

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

 



On Thu, Oct 6, 2011 at 5:21 PM, Nick Tkach <ntkach@xxxxxxxxx> wrote:
> Is there some way to make a RewriteRule concat together two
> back-references?  What I want to do is take the REQUEST_URI and the
> QUERY_STRING of a request and use the two together as a key into a
> map.
>
> So if I have a request like this:
>
> http://mysite.com/bar/startpage?arg1=a&arg2=b
>
>  and I want to rewrite that to
>
> http://mysite.com/foo/endpage?arg3=c&arg4=d
>
> Given an entry in the map file like
>
> bar/startpage?arg1=a&arg2=b    foo/endpage?arg3=c&arg4=d
>
>
> I was trying some combination like
>
> RewriteMap map2 txt:/redirects-map.txt
>
> RewriteCond %{REQUEST_URI} ^/bar/startpage
> RewriteCond %{QUERY_STRING} arg1=a&arg2=b
> RewriteCond %{REQUEST_URI} (.*)
> RewriteCond %{QUERY_STRING} (.*)
> RewriteRule .* ${map2:%1%2}? [L,NC,R=302]
>
>
> That seems to only try to do the map lookup based on the QUERY_STRING.
>  Obviously the second match is over-riding the first, but I'm not
> quite sure how to stop that.

Yes, and there is no way around that. What you can do instead is
capture the REQUEST_URI as a RewriteRule backref:

RewriteCond %{REQUEST_URI} ^/bar/startpage
RewriteCond %{QUERY_STRING} arg1=a&arg2=b
RewriteCond %{QUERY_STRING} (.*)
RewriteRule (.*) ${map2:$1%1}? [L,NC,R=302]

Cheers

Tom

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