Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite help!

         

Tony_Guy

7:30 pm on Jul 21, 2006 (gmt 0)

10+ Year Member



Any help would be really appreciated. I've spent the past hour searching for info for something I thought would be common but it seems not...

All I need to do is to change a dynamic url to a different dynamic one using htaccess (although the actual parsed data for each will stay the same). It becomes difficult because as you no doubt no you can't use a dynamic url in the standard RewriteRule statement.

So I need to change...

example.com/folder/index.php?args=1&args=2

to

example.com/newfolder/newfile.php?args=123

if anybody knows how to do this in htaccess it would be very, very appreciated.

Thanks.

Tony_Guy

7:33 pm on Jul 21, 2006 (gmt 0)

10+ Year Member



Oops - I just re-read that and thought I'd better clarify...the data will stay the same in that it will be constant in the first url i.e. it will always be?args=1&args=2 but will be different in the new url i.e.?args=123

Hope that all makes sense.

Tony_Guy

8:25 pm on Jul 21, 2006 (gmt 0)

10+ Year Member



Never mind found it. It was answered here a ways back but dug it out in the end....

RewriteCond %{QUERY_STRING} ^args1=1&args2=2$
RewriteRule ^folder/index.php$ [site.com...] [R=301,L]

seems to work fine. If anyone notices something 'not quite right' with the above I'd be grateful for details othersie it seems fine :)

jdMorgan

8:35 pm on Jul 21, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Looks good to me...

The only thing I see that's 'not quite right' is that you should escape the period in your RewriteRule pattern, because an unescaped period is a regular expressions token meaning 'any single character.'


RewriteCond %{QUERY_STRING} ^args1=1&args2=2$
RewriteRule ^folder/inde[b]x\.p[/b]hp$ http://www.example.com/newfolder/newfile.php?newargs=123 [R=301,L]

Glad you got it sorted!

Jim