Apache redirection magic

Apache redirection magic

by Martin Dougiamas -
Number of replies: 5
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Can anyone more familiar with Apache RedirectMatch give me the correct magic to redirect:

http://moodle.org/bugs/bug.php?op=show&bugid=xxxx

and bugid embedded in other parameters:

http://moodle.org/bugs/bug.php?op=show&bugid=xxxx&blah=blah

to

http://tracker.moodle.org/browse/MDL-xxxx
Average of ratings: -
In reply to Martin Dougiamas

Re: Apache redirection magic

by Pablo Etcheverry -
Picture of Core developers
Sorry, but I don't think RedirectMatch is enough for that complex statement. If you could use mod_rewrite, then the rule woud look like this:
RewriteEngine on
RewriteCond %{QUERY_STRING} ^op=show&bugid=([0-9]+)&?(.*)$
RewriteRule ^bugs/bug.php$ http://tracker.moodle.org/browse/MDL-%1 [R,L]
I just tested it and worked like a charm, EXCEPT that the final URL looks like this:

http://tracker.moodle.org/browse/MDL-1234?op=show&bugid=1234&blah=blah

Of course, you can ignore the part after the "?", but I'm sure that someone else can improve my solution.

Cheers,
Pablo
In reply to Pablo Etcheverry

Re: Apache redirection magic

by Nicolas Martignoni -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Isn't it
RewriteRule ^bugs/bug.php$ http://tracker.moodle.org/browse/MDL-$1 [R,L]
with a $ (dollar) sign instead of a % (per-cent) ?
In reply to Pablo Etcheverry

Re: Apache redirection magic

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Thanks, Pablo! approve

When we turn the old bugs system off I'll implement that.