Welcome to WebmasterWorld Guest from

Forum Moderators: phranque

Message Too Old, No Replies

Redirect with parameter

Redirecting http://mysite.com/buy.asp?123 to http://mysite.com/buy.php?123



6:58 am on Apr 2, 2003 (gmt 0)

10+ Year Member

I have recently moved my hosting from Windows to a Linux server. The previous affiliate tracking system was written in ASP which now been converted to php. But many of my affiliates still have the old links on their websites.
I can redirect the the .asp links to the new .php pages with .htaccess. But I don't know how to pass the parameters with the redirect.

[mysite.com...] --> [mysite.com...]

Any ideas?


2:31 pm on Apr 2, 2003 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member


Something like this will work. The "%1" in the RewriteRule back-references the value that matches inside the parentheses in the RewriteCond, so the variable "123" in your example is passed on to the new URL.

RewriteCond %{QUERY_STRING} (.*)
RewriteRule ^buy\.asp$ /buy.php?%1 [R=301,L]

Good reference: Introduction to mod_rewrite [webmasterworld.com]



6:19 pm on Apr 4, 2003 (gmt 0)

10+ Year Member

Hi Jim,
Thanks for the tip, I'll try it out and let you know.



Featured Threads

Hot Threads This Week

Hot Threads This Month