views:

93

answers:

2

I have a project that uses the moodle library. I had to change the URL from moodle.example.com to learn.example.com, due to a client request.

I thought this would be an easy change, but alas moodle inserts all links and images in with the complete url instead of the relative url.

Is it possible using mod-rewrite to point all requests to moodle.example.com to learn.example.com and maintain the query string?

Example:

I want a request to: http://moodle.example.com/course/view.php?id=2&topic=1 to go to http://learn.example.com/course/view.php?id=2&topic=1.

Is this possible?

Thanks,

Josh

+2  A: 

Try this rule:

RewriteCond %{HTTP_HOST} =moodle.example.com [NC]
RewriteRule ^ http://learn.example.com%{REQUEST_URI} [L,R=301]
Gumbo
Damn, faster than me. Try this cheat sheet for mod-rewrite: http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet/
Rob Stevenson-Leggett
Something is still redirecting it to the login page. What could I be doing wrong?
resonantmedia
A: 

In addition to the apache rewrite rules, it may also be worth looking at the moodle documentation on migration: http://docs.moodle.org/en/Moodle_migration

In particular look out for admin/replace.php. This tool can help you to rewrite links across all text in the moodle database at the same time.

digitalsean