Apache redirection magic

Apache redirection magic

Martin Dougiamas -
回帖数:5
Core developers的头像 Documentation writers的头像 Moodle HQ的头像 Particularly helpful Moodlers的头像 Plugin developers的头像 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
回复Martin Dougiamas

Re: Apache redirection magic

Pablo Etcheverry -
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
回复Pablo Etcheverry

Re: Apache redirection magic

Nicolas Martignoni -
Core developers的头像 Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像 Testers的头像 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) ?