Forum Moderators: phranque

Message Too Old, No Replies

Mod Rewrite Simple Question

I feel dumb

         

iJeep

2:56 pm on Sep 16, 2004 (gmt 0)

10+ Year Member



i have been using mod rewrite for years, but this extremely simple redirect is giving me problems. Instead of redirecting it does nothing.


RewriteBase /
RewriteRule .*a=([0-9]+).*$ /other_dir/?ref=$1 [R=301,L]

I just want it to take any url with a= in the query string and rewrite it to a new url where a=ref. a is always a positive integer.

jdMorgan

3:09 pm on Sep 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See RewriteCond %{QUERY_STRING} in the mod_rewrite documentation.
A query string is not part of a URL (by definition, it is data attached to a URL, to be passed to the resource at that URL), and so must be handled separately.

Jim

iJeep

3:48 pm on Sep 16, 2004 (gmt 0)

10+ Year Member



Thank You!

Here is what I needed in case anybody else has the same problem.


RewriteCond %{QUERY_STRING} a=([0-9]+)
RewriteRule $ test.php?ref=%1 [R=301,L]

hiker_jjw

7:31 pm on Sep 17, 2004 (gmt 0)



Actually, it will work the other way too, but you must make your regular expressions "non-greedy" using .*?

Cheers,
Jeff