Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: mod_alias RedirectMatch help |
|
Author |
|
JonAntoine
Joined: 10 Aug 2006 Posts: 4 Location: Portland, OR
|
Posted: Fri 25 Aug '06 20:24 Post subject: mod_alias RedirectMatch help |
|
|
Hi,
I am using RedirectMatch to redirect many bad links from on old website to a new website. One particular link is proving to be harder to redirect than the others for two reasons.
1. It is a link that references a virtual host
2. The old link has a query string and the values of some variables need to be reassigned to new variables.
Inside the tags of my ssl virtual host, I am using RedirectMatch to redirect the following link:
https://secure.myserver.com/order.php?var=xxxxxx
to the new link:
https://secure.myserver.com/buynow/step1?newvar=xxxxxx.
This is the line in the virtual host tag:
RedirectMatch 301 /order\.php\?var=(.*) /buynow/step1.php?newvar=$1
I am pretty sure this is a syntax error but I can't figure it out. Again, I have other simpler redirects working just fine, but not for the virtual host.
All help is appreciated.
Jon |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Fri 25 Aug '06 20:44 Post subject: |
|
|
Why you don't redirect with PHP? It is much easier!
in order.php
Code: |
<?php
/* Redirect auf eine andere Seite im aktuell angeforderten Verzeichnis */
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'buynow/step1?newvar=' . $_GET['var'];
header("Location: http://$host$uri/$extra");
exit;
?>
|
|
|
Back to top |
|
JonAntoine
Joined: 10 Aug 2006 Posts: 4 Location: Portland, OR
|
Posted: Fri 25 Aug '06 22:37 Post subject: |
|
|
James Blond,
Thanks for the suggestion. This will do for a temporary fix, but I was hoping to not have to create the file at all and have apache handle all redirecting. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
|
Back to top |
|
|
|
|
|
|