Forum Moderators: phranque

Message Too Old, No Replies

rewrite

not quite working returning $1 twice

         

WhosAWhata

5:25 am on May 4, 2004 (gmt 0)

10+ Year Member



i have this as a .htaccess file

RewriteEngine on
RewriteRule ^((Jan¦Feb¦Mar¦Apr¦May¦Jun¦Jul¦Aug¦Sep¦Oct¦Nov¦Dec)[0-9]{2})/([0-9]{2})$ http://site.com/folder/page2.php?month=$1&day=$2
RewriteRule ^((Jan¦Feb¦Mar¦Apr¦May¦Jun¦Jul¦Aug¦Sep¦Oct¦Nov¦Dec)[0-9]{2})$ http://site.com/folder/page1.php?month=$1

say i access /May04/02

$month = May04
$day = May

$day should equal 02, but it doesn't... why

jdMorgan

5:38 am on May 4, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Because "day" is back-referenced into $3 in the first rule, not $2.
To figure out which back-reference number to use, count left parentheses.
In rule number 1, $1 contains the month and the day, $2 contains the month, and $3 contains the day.
This can sometimes be useful, but here it is causing your problem.

Jim

WhosAWhata

2:02 am on May 5, 2004 (gmt 0)

10+ Year Member



ahh, i see
the world makes sense again
thanks Jim