Issue
I want to redirect all pages that call a script to call a different script and also to change the name of a parameter. I also want to lose a folder from the url. No matter what I try I get an error.
For testing purposes before we go live on the new site, where these pages will be redirected, we have a domain set up that points to the new file locations and need to change that too as part of the redirect (after we go live the old domain will be pointed to the new domain location).
Because the url calls a program (prodpage.pgm) and Srcipt Aliases are also needed, this redirect MUST be done in the httpd.conf file not in .htaccess, which means I have to restart Apache every time I change anything, so I can't just
The old url we want to redirect is of the form:
http://www.olddomain.com/b2c/b2citmdsp.pgm?pp_skmno=18297
and should be redirected to:
http://www.newdomain.com/prodpage.pgm?item=18297
I use a 301 redirect as follows to do this but it doesn't work:
RedirectMatch 301 ^/b2citmdsp.pgm\?pp_skmno=(.*) http://www.newdomain.com/prodpage.pgm?item=$1
In summary, I need to:
(a) lose the /b2c/ (b) change b2citmdsp.pgm to prodpage.pgm (c) retrieve the parameter value for pp_skmno and use it with the new url
Any ideas on what I am doing wrong please, or is this just not possible.
Also, when you do a redirect, does it change the url, so that you can use a subsequent redirect to further modify it? In this case I might be able to use 2 or 3 redirects, but I feel sure this must be possible in one, it's just I struggle with regex sometimes.
Solution
You can match the following regex:
http:\/\/.+\/b2citmdsp\.pgm[^=]+=(.*)
and replace with:
http://www.newdomain.com/prodpage.pgm?item=\1
Answered By - sshashank124 Answer Checked By - Cary Denson (WPSolving Admin)