Apache redirection magic

Apache redirection magic

by Martin Dougiamas -
Number of replies: 5
Immàgine de Core developers Immàgine de Documentation writers Immàgine de Moodle HQ Immàgine de Particularly helpful Moodlers Immàgine de Plugin developers Immàgine de 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 -
Immàgine de 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 -
Immàgine de Core developers Immàgine de Documentation writers Immàgine de Particularly helpful Moodlers Immàgine de Plugin developers Immàgine de Testers Immàgine de 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 -
Immàgine de Core developers Immàgine de Documentation writers Immàgine de Moodle HQ Immàgine de Particularly helpful Moodlers Immàgine de Plugin developers Immàgine de Testers
Thanks, Pablo! approve

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