Topic: One forum on two domains

Hi. We have the same forum on two domains:
http://neverhood.etomite.cz/online/ and http://neverhood.etomite.sk/online/

One domain is mirroring the other one. Our users from Slovakia usually use the .sk address, users from Czech rep. the .cz address. Actually it is no problem using other variant, but the link to our website in the top (Web - linking ../) should go to right variant, cause the language of the content is set via .cz or .sk in URL.

In 1.2.x it is easy to use, users can use both variant and sometimes there are problems with administration using the domain that is not set in Config - it gives refer error (protection of sending form from other domain). That I can change in some files by disabling this protection or put one OR to the IF.
In 1.2.x easy workaround, no prob.

In 1.3 it redirects to "right" domain while loging in/out (as phpBB 2.0.x used to do).

The question is: How can I run one forum or two domains without problems?

BTW if there is a way to set guest language based on domain name, it'll be great.

Re: One forum on two domains

This should be pretty easy to do as an extension. You have to check for the request URL and set the variable $base_url accordingly.

The guest language thing should be possible with that, too. Do you need any coding help?

FluxBB - v1.4.8

3 (edited by churchyard 2008-11-23 17:40)

Re: One forum on two domains

You mean setting base URL not from the DB, but from the URL?
And the same with language?

I think I am able to write it this way to code of PunBB, but I'm not sure, if I can make a extension. If you can, I would be beholden to you wink

Lets put .cz as a config option and Czech as default language.

Then:

if ($_SERVER['HTTP_HOST'] == "neverhood.etomite.sk") {
  $base_url = 'http://neverhood.etomite.sk/online';
  $dont_know_what = 'Slovak';
}

Is that like that easy?

4 (edited by User33 2008-11-23 18:12)

Re: One forum on two domains

Why not just

$base_url = 'http://'.$_SERVER['HTTP_HOST'].'/online';

Though, this creates an issue with cookies and sessions. (Both my solution and yours)

I'd get a .com domain and let the users choose the language and set it on a cookie that could be read by both the forum and your pages.

Edit: For your $dont_know_what variable:

$lang = array_pop(explode('.', $_SERVER['HTTP_HOST'])); //should return "sk" or "cz"

Re: One forum on two domains

Just thinking, if this would not destroy the protection. But it would not, cause it will still check, if refer is the same as http_host, so it should work as protection, shouldn't it?

No problem with cookies, cause user usually use only one of the domains.

And if I set $lang, it will change default language? Or it destroys what had user chosen in his or her profile?

Re: One forum on two domains

I'm not sure how $lang really works (haven't checked that part of PunBB, yet), but you could do something like:

if($forum_user['is_guest'])
{
    $snip = array_pop(explode('.', $_SERVER['HTTP_HOST']));
    if($snip=='sk') $use = 'slovak';
    elseif($snip=='cz') $use = 'czech';
    //Change the language pack according to $use
}

Re: One forum on two domains

Second part of the solution: Where exactly I should put this piece of code, when I want to have it as and extension? Not manually modifying files?

8 (edited by User33 2008-11-23 20:09)

Re: One forum on two domains

Like I said, I have yet to find out where/when the language packs are loaded. Try to look at header.php, it's probably there.

Re: One forum on two domains

The best way is to check it when creating config cache, I think.