MyBB Community Forums

Full Version: domain aliases and configuration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
As most of you are not aware, including a "www." in a url when entering it into your browser is a meaningless exercise (see no-www.org for specifics). So all the websites we put together will work with or without the "www.".

Even if you don't agree with the previous paragraph, the other common situation is when one uses "yourdomainname.com", "yourdomainname.org", "yourdomainname.co.uk", etc, all mapping to the same primary domain.


However, the installation script generates technically inaccurate settings - the domain name should not be hard-coded into the configuration file.

settings.php:

old:
$settings['bburl'] = "http://yourdomainname.com";

new:
$settings['bburl'] = 'http://' . $_SERVER['HTTP_HOST'];



Because of this, the second time you visit the site, you will get the message "Welcome Guest" on the homepage, then when you go to the login page, you will already be logged in.

[The change suggested above is incorrect, please see my next post below]
I've often thought about this issue, too.

I have two aliases for my domain - one for my intranet, and one that gets there via the internet. I use my intranet address most of the time (doesn't use up my ISP bandwidth), but on occasion I use the other domain name to make sure it is accessible from outside.

One problem, though: settings.php is rewritten everytime you change a setting in the ACP, so how do you make this stick?
You are correct about the rewriting of settings.php, so the more appropriate solution would be to add the following code to the end of inc/init.php, just above the line "$mybb->settings = $settings;"

  $protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
  $settings['bburl'] = str_replace('*', $protocol . $_SERVER['HTTP_HOST'], $settings['bburl']);

This will change the meaning of the "Board URL" admin setting. Instead of having "http://yourdomain.com/forumpage", replace the first section with "*", so it would become "*/forumpage". If you had "http://forums.yourdomain.com", it would change to just "*"

Any devs want to chime in on this fix? Is it safe to put on our boards? Is it fixed in the SVN?
It's safe, but I haven't tried it so I can't guarantee if it works or not. At this point in time it's not in SVN
Quote:However, the installation script generates technically inaccurate settings
The installer uses whatever you specify for the board URL - it attempts automatic detection of it too.

Quote: - the domain name should not be hard-coded into the configuration file.
Actually, it should be hard coded into MyBB's settings.php. Firstly, because of the cookie settings, and secondly because of emails being sent out by the board.
I'm going to move this to the suggestions forum for now, since it's not exactly a bug.
I know for a fact that cookies can be shared across different hosts under the same domain (foo.mydomain.com and bar.mydomain.com), but not across domains (mydomain.com and mydomain.net).