开发者

Rewriting a Subdomain with mod-rewrite

开发者 https://www.devze.com 2022-12-28 03:39 出处:网络
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 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 comp开发者_StackOverflowlete 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


Try this rule:

RewriteCond %{HTTP_HOST} =moodle.example.com [NC]
RewriteRule ^ http://learn.example.com%{REQUEST_URI} [L,R=301]


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号