开发者

.htaccess Redirection for Querystrings

I have an old website that URLs were like /page.aspx?sch=XXXX&prg=YYYY. I want to redirect 开发者_Python百科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...


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜