How to capture a 'sub-section' of a URL in a rewrite rule?
Posted
by George Edison
on Stack Overflow
See other posts from Stack Overflow
or by George Edison
Published on 2010-05-10T22:46:05Z
Indexed on
2010/05/22
7:30 UTC
Read the original article
Hit count: 213
I know the title is a little bit strange, but here is what the URLs look like:
/user/xxx/page
/user/xxx/page?error=yyy
The rule for the first URL looks something like this:
RewriteRule ^user/(\d+)/page$ something.pl?id=$1 [L]
And to make it work with the second URL, it becomes:
RewriteRule ^user/(\d+)/page(error=\d+)?$ something.pl?id=$1 [L]
My question is... how do I capture the error number? I tried both of these:
RewriteRule ^user/(\d+)/page(error=(\d+))?$ something.pl?id=$1&error=$2 [L]
RewriteRule ^user/(\d+)/page(error=(\d+))?$ something.pl?id=$1&error=$3 [L]
But it isn't working...
How can I do this?
© Stack Overflow or respective owner