Forum Moderators: phranque

Message Too Old, No Replies

RewriteRule Pattern

2nd match pattern notworking

         

anjanesh

4:33 pm on Feb 6, 2007 (gmt 0)

10+ Year Member



I have this RewriteRule in my .htaccess file in test folder :

RewriteRule ^new\/(.+)\.htm\?a=(.+)$ script.php?x=$1&y=$2
# RewriteRule ^new\/(.+)\.htm$ script.php?x=$1

[localhost...]
returns 404
And if I uncomment the 2nd rule, it works obeying that rule.

Can anyone pl me what Im doing wrong here?

Using Apache 2.x
Thanx

jdMorgan

6:14 pm on Feb 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, RewriteRule cannot 'see' query strings. Use a RewriteCond to test and back-reference the query string:

RewriteCond %{QUERY_STRING} ^a=([^&]+)$
RewriteRule ^new\/([^.]+)\.htm$ script.php?x=$1&y=%1 [L]

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

anjanesh

3:48 am on Feb 15, 2007 (gmt 0)

10+ Year Member



Wow. Thanx for the fix and links.