Hi Chris,

Chris Devers wrote on 07.03.2005:

>On Mon, 7 Mar 2005, Jan Eden wrote:
>
>> But I need some rule to do this:
>> 
>> http://mysite.com/pages?id=1234 -> http://mysite.com/pages/1234
>> 
>> And since mod_rewrite does not parse the query string, I have a 
>> problem here.
>
>So use redirect instead of rewrite:
>
>    RedirectMatch /pages?id=(.*) http://mysite.com/pages/$1
> 
>Won't that work?
>

Yes, it would. Doh! I was so focussed on mod_rewrite that I forgot about 
simpler options.

Anyway, I finally figured something out which works with RewriteRules. My first 
attempt was this:

RewriteCond %{QUERY_STRING} ([0-9]+)
RewriteRule ^pages$ html/%1.html [L,NC]

which only works if the QUERY_STRING is part of the URL (i.e. I do a GET 
request)

This was a basis for the following construct:

RewriteCond %{QUERY_STRING} id=([0-9]+)
RewriteRule ^pages$ pages/%1? [R,NC]
RewriteRule ^pages/([0-9]+) html/$1.html [L,NC]

which gives me what I need, turning the URL with a query string into something 
like pages/1234 and invisibly rewriting the resulting URL.

Thanks again for your help,

Jan
-- 
I'd never join any club that would have the likes of me as a member. - Groucho 
Marx

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to