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 :)
I have the same exact issue.
You will just have to pick one of the three domains and tell your users to use that one.
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.
Yes, but that was exactly what I was trying to avoid. No workaround possible? Not even using different settings dinamically?
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.
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 :)
Webhosting talk forum did it.
http://www.webhostingtalk.com/index.php
http://www.webhosting-talk.com/index.php
Look at the board:
http://www.webhostingtalk.com/forumdisplay.php?f=1
http://www.webhosting-talk.com/forumdisplay.php?f=1
Any idea how they did it?
You could probably do something like
$boardurl = $_SERVER['HTTP_HOST'].'/forum';
In your Settings.php
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"
???
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';
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';
;)
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..
// 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..
Interesting find... I'll have to play with that sometime to see what I can get out of it.
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... ;)
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://
Both Ben_S and Daniel codes seem to work... thanks a lot to all of you!! :)