News:

Join the Facebook Fan Page.

Main Menu

Multi-domain forum

Started by rebus, November 09, 2006, 03:56:56 PM

Previous topic - Next topic

rebus

Don't know if this is the right board, but I'm going to try  ;)

I own three domains all pointing to the same forum on the same webspace. It works, but if one doesn't access the forum by the domain recorded in the settings file, it has sometimes login or cookie problems. If I log in by the default domain, no problem. But I would like users to use the domain they prefer. How could this be worked out? Maybe using three different settings files and a kind of script which detects the domain and tells SMF to use the proper setting? If anyone has ideas, thanks in advance  :)

bank robber

I have the same exact issue.

Oldiesmann

You will just have to pick one of the three domains and tell your users to use that one.
Michael Eshom
Christian Metal Fans

Daniel15

Unfortunately, the cookie can only work on one domain (the 'cookie domain'). As Oldiesmann said, you'll need to pick one of the domains, and tell the users to use that one.
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

rebus

Yes, but that was exactly what I was trying to avoid. No workaround possible? Not even using different settings dinamically?

Ben_S

Is there a reason why you really really need to do this, you are better off picking one and using that alone for all sorts of reasons, not least search engine positioning.
Liverpool FC Forum with 14 million+ posts.

rebus

Thanks. I don't really really need that but, if there is a way to do it, I'd like it, because the different domains were chosen by users and they want to use the one they chose. That's all  :)


Ben_S

You could probably do something like

$boardurl = $_SERVER['HTTP_HOST'].'/forum';

In your Settings.php
Liverpool FC Forum with 14 million+ posts.

rebus

Quote from: Ben_S on November 10, 2006, 08:32:36 AM
You could probably do something like

$boardurl = $_SERVER['HTTP_HOST'].'/forum';

In your Settings.php

Thanks a lot! It almost works but gets the URL doubled, something like "http://www.domain.com/forum/www.domain.com/forum"

???

Ben_S

Hmm in that case try something like

if($_SERVER['HTTP_HOST'] == 'www.firstdomain.com')
    $boardurl = 'http://www.firstdomain.com/forum';
elseif($_SERVER['HTTP_HOST'] == 'www.seconddomain.com')
    $boardurl = 'http://www.seconddomain.com/forum';
elseif($_SERVER['HTTP_HOST'] == 'www.thirddomain.com')
    $boardurl = 'http://www.thirddomain.com/forum';
else
    $boardurl = 'http://www.firstdomain.com/forum';
Liverpool FC Forum with 14 million+ posts.

Daniel15

Quote from: rebus on November 10, 2006, 10:45:55 AM
Quote from: Ben_S on November 10, 2006, 08:32:36 AM
You could probably do something like

$boardurl = $_SERVER['HTTP_HOST'].'/forum';

In your Settings.php

Thanks a lot! It almost works but gets the URL doubled, something like "http://www.domain.com/forum/www.domain.com/forum"

???
I think it should have been:
$boardurl = 'http://'.$_SERVER['HTTP_HOST'].'/forum';
;)
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

SleePy

I came across the same problem..

I solved mine this way..


//$boardurl = 'http://mydomain.com/forum'; # URL to your forum's folder. (without the trailing /!)
$siteurl_1 = 'mydomain.com';
$siteurl_2 = 'myotherdomain.com';

$boardurl = 'http://' . ($_SERVER['HTTP_HOST'] == $siteurl_2 ||  $_SERVER['HTTP_HOST'] == 'www.'.$siteurl_2 ? $siteurl_2 : $siteurl_1 ) . '/forum'; # URL to your forum's folder. (without the trailing /!)


Also..
I think this might be a future feature or something..

Code ('Subs-Auth.php') Select

// Any alias URLs?  This is mainly for use with frames, etc.
if (!empty($modSettings['forum_alias_urls']))
{
$aliases = explode(',', $modSettings['forum_alias_urls']);

$temp = $boardurl;
foreach ($aliases as $alias)
{
// Fake the $boardurl so we can set a different cookie.
$alias = strtr(trim($alias), array('http://' => '', 'https://' => ''));
$boardurl = 'http://' . $alias;

$cookie_url = url_parts(!empty($modSettings['localCookies']), !empty($modSettings['globalCookies']));

if ($cookie_url[0] == '')
$cookie_url[0] = strtok($alias, '/');

setcookie($cookiename, $data, time() + $cookie_length, $cookie_url[1], $cookie_url[0], 0);
}

$boardurl = $temp;
}


I added the variable to my modsettings file and gave it a text string.. Set it up by following what the code was doing.. But it didn't work :(.. wish it would.. Would be cool to have my cookies across my domains..
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Oldiesmann

Interesting find... I'll have to play with that sometime to see what I can get out of it.
Michael Eshom
Christian Metal Fans

SleePy

lol.. Hopefully you get better luck than I did.. I wasn't able to get any affect out of it.. if you want I can hook you up on my site to play with it, I got 3 domains... ;)
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Ben_S

#15
Quote from: Daniel15 on November 10, 2006, 10:06:10 PM
Quote from: rebus on November 10, 2006, 10:45:55 AM
Quote from: Ben_S on November 10, 2006, 08:32:36 AM
You could probably do something like

$boardurl = $_SERVER['HTTP_HOST'].'/forum';

In your Settings.php

Thanks a lot! It almost works but gets the URL doubled, something like "http://www.domain.com/forum/www.domain.com/forum"

???
I think it should have been:
$boardurl = 'http://'.$_SERVER['HTTP_HOST'].'/forum';
;)

Doh you are right, completly forgot about the http://
Liverpool FC Forum with 14 million+ posts.

rebus

Both Ben_S and Daniel codes seem to work... thanks a lot to all of you!!  :)

Advertisement: