views:

18

answers:

1

Hi,

I have an old website that URLs were like /page.aspx?sch=XXXX&prg=YYYY. I want to redirect those old URLs to my new website's URLs. I'm trying to use an .htaccess file to do the trick but I couldn't get it work. What I want is:

/page.aspx?sch=XXXX&prg=YYYY ==> /page/sch/XXXX/prg/YYYY

If someone could helped me, I'd be very pleased.

Thanks...

+2  A: 

If there are only these two URL parameters and they are only used in this order, you can do the following:

RewriteCond %{QUERY_STRING} ^sch=([^&]+)&prg=([^&]+)$
RewriteRule ^page\.aspx$ /page/sch/%1/prg/%2? [L,R=301]

Otherwise you will need to extract these parameters one by one and put them in in right order before doing that redirect.

Gumbo
That was what I was looking for, works great. Thanks...
Burak Erdem