httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tom Evans <tevans...@googlemail.com>
Subject Re: [users@httpd] Re: Vanity URL Rewrites Best Practices?
Date Thu, 06 Oct 2011 16:33:57 GMT
On Thu, Oct 6, 2011 at 3:00 PM, Nick Tkach <ntkach@gmail.com> wrote:
> Just to answer my own question, in case it helps someone else down the
> road, what I was missing was that inside the curly braces you need to
> dereference the variable with % rather than $.  So the right version
> of what I posted above is:
>
>  RewriteMap vanmap txt:/tmp/map.txt
>
>  RewriteCond %{REQUEST_URI} ^/mmh/
>  RewriteCond %{QUERY_STRING} \%2F(\w+)\.xml$
>
>  RewriteRule .* /mmh/${vanmap:%1}? [L,NC,R=302]
>

Since this is for posterity, I have to say 'No!'.

In both the RewriteRule and the RewriteCond, %N refers to back
references in the last matched RewriteCond, and $N refers to back
references in the RewriteRule. It doesn't matter one jot that it is
'inside the curly braces', it matters where the data comes from.

This is mentioned in both the RewriteCond and the RewriteRule documentation:

http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewritecond
http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule

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