Forum Moderators: phranque

Message Too Old, No Replies

Theme-based Domain Names - Would this Work?

Can I modify a theme so that is uses mod_rewrite to change the domain name?

         

ferndog

8:52 pm on Jan 9, 2012 (gmt 0)

10+ Year Member



Hello,

I’ve been searching high and low for someone who can give me an informed response about the issue I’m about to describe. In fact, I paid for a membership on this forum for this explicit reason. Short of begging, which may come later if I no one responds to this message, I’d be very grateful for any feedback. I’ll try to break this down as clearly as I can…

Background:
Moodle is a Learning Management System (LMS), which basically is a CMS for eLearning. Like other CMS environments, Moodle (www.moodle.org) uses themes. In Moodle, each course can have a separate theme. The issue I’m about to describe is not a Moodle-specific thing, however, as it could apply to any CMS that use themes. Moodle just happens to be the CMS that I’m using.

Setting the stage:
Let’s assume that my Moodle site is www.MyMoodleSite.com and that it has two courses, Course 1 and Course 2, and that each one is using its own custom theme.

My Goal:
I am looking to display different domain names for different courses within the SAME Moodle site, like this:

Site Level: www.MyMoodleSite.com
Course 1: www.course1.com
Course2: www.course2.com

In other words, when I enter Course 1, rather than show a URL like www.MyMoodleSite.com/course/view.php?id=85, it should display www.course1.com. When I exit Course 1 and return to the front page (site level), the domain name should return to www.MyMoodleSite.com.

My Thinking:
Again, let’s assume that each of the above is using its own custom theme, like this:

Site Level (using theme A)
Course 1 (using theme B)
Course 2 (using theme C)

I would like to modify these themes (ie. add code, .htaccess file, whatever) so that each theme makes use of mod_rewrite (or alternative module/script) to change the domain name while the theme is in use. In short, the theme would trigger the domain name change.

If this were possible, the only missing piece of the puzzle would be to change the DNS CName record so that the www.course1.com and www.course2.com point to the relevant courses (example: www.course1.com > www.MyMoodleSite.com/course/view.php?id=85). This would allow courses to be accessed directly (outside www.MyMoodleSite.com).

The Big Question:

Would this work? If not, is there another way of achieving the same thing? I am not a coder myself but if this is possible, then my next step would be to try to find someone who can make this happen.

Again, any suggestions, ideas, thoughts would be much appreaciated.

Thanks,
Fernando

penders

9:57 pm on Jan 9, 2012 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You can certainly access the same site from different domains (Parked or Add-On domains in cPanel) and then in script (.htaccess or PHP) you can presumably check the HOST header to see from which domain the page has been accessed and then mod_rewrite or serve the appropriate content. So, IMHO I would say this should work.

ferndog

4:28 pm on Jan 10, 2012 (gmt 0)

10+ Year Member



Thanks Penders, that sounds hopeful!

I've gone ahead and posted this project on one of the popular coder-for-hire sites. Hopefully I'll get some bites!

Any other feedback is welcome.

ferndog

7:43 pm on Jan 10, 2012 (gmt 0)

10+ Year Member



I got a response on the Moodle forums from a user that basically said it's not a viable plan. His main reasons are as follows:

"mod_rewrite operates at a different level from PHP, so PHP can't influence mod_rewrite. Putting .htaccess in your themes directory will not affect anything -- only the .htaccess from the top-level script is used."

Still looking for more opinions on the matter. Please feel free to comment.

Thanks,
Fernando