by Bruno Soldier.
I agree about the "magic" - using HTTP_HOST in config.php seemed to involve too many assumptions about what was placed in the database when the instance was created.
However, I have it working now, using mod_rewrite.
The code is:
<IfModule rewrite_module>
Options Indexes FollowSymLinks +IncludesNOEXEC
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mydomain\.org$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.org/$1 [L,R=301]
</IfModule>
This checks for mydomain.org lacking "www" and rewrites to
Functionality, CSS, etc. seem normal.
The rewrite occurs "on-the-fly" before server processing begins, so Moodle should only see the "www" version.
Would you forsee any problems with this?