0

There is an old link coming to my site that ends with sc_purchase_a.asp?discode=foo&ProID=bar. I want to redirect that to /courses/shop/4u.php?discode=foo. This is what I've done so far, but its not working.

RewriteRule ^sc_purchase_a.asp?discode=(\w+)&ProdID=(\w+)/?$ /courses/shop/4u.php?discode=$1 [QSA]

This doesnt seem to work.

Based on starkeen's answer, I came up with this, but it is not working and now gives me 500 errors.

RewriteCond %{THE_REQUEST} /sc_purchase_a\.asp\?discode=([^&]+)&ProID=.+ [NC]
RewriteRule ^ /courses/shop/4u.php?discode=%1 [L,R]
1
  • 1
    Try: /page.php?code=$1 [L] Commented Feb 1, 2017 at 7:52

1 Answer 1

2

QueryString is not part of match in RewriteRules pattern. To manupulate query string ,you need to use a RewriteCond

RewriteEngine on


RewriteCond %{THE_REQUEST} /page\.asp\?code=([^&]+)&id=.+ [NC]
RewriteRule ^ /page.php?code=%1 [L,R]
Sign up to request clarification or add additional context in comments.

3 Comments

Sorry to be an ignoramus, but what do you mean by {THE_REQUEST}?
THE_REQUEST is an apace predefined variable it represents the full request line sent by client to the server ,eg GET /page.asp?code=foo&id=bar HTTP 1.1
This is working fine on my apache server. Please check your error log for info about the error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.