Forum Moderators: phranque
What I am trying to do is to to rewrite example.php?page=111 to stuff.php?parent_id=50&page=111
Where page is a number from 1 to 100
Jim on here kindly gave me an example that I think has lead me in the right direction but I can't get it to work. The example he gave was
RewriteCond %{HTTP_QUERY_STRING} ^(page=[^&]+)$
RewriteRule ^example\.php$ /stuff.php?parent_id=50&%1 [L] There are a couple of things I did not understand with this such as the ^& and the %1. I did not try it at the time as I was tied up at my day job and it seemed a bit late to rply to the original thread. Anyway when I tried it I had no luck with it and so did a bit of reading and came up with the following.
RewriteCond %{HTTP_QUERY_STRING} ^(page=[0-9]+)$
RewriteRule ^example.php$ stuff.php?parent_id=50&$1 [L] This does not work either and I can't see why. I'm sure I have misunderstood the syntax. When I typre a url such as [somesite.com...] I get a 404 error as the rule does not appear to be triggered at all.
RewriteCond %{[b]QUERY_STRING[/b]} ^(page=[0-9]+)$
RewriteRule ^example\.php$ stuff.php?parent_id=50[b]&%1[/b] [L]
"$1" refers to the contents of the first matched parenthesized subpattern in the RewriteRule pattern.
"%1" refers to the contents of the first matched parenthesized subpattern in the last-matched RewriteCond pattern.
For more information, see the documents cited in our forum charter [webmasterworld.com] and the tutorials in the Apache forum section of the WebmasterWorld library [webmasterworld.com].
Jim
I never even thought to look in the forum charter but I have spent more than a couple of hours reading search engine results before posting the question.
Once again many thanks.
Brian