1 s0l1dsn8k3 Nov 23, 2006 21:14
3 s0l1dsn8k3 Nov 25, 2006 17:46
Sub-domains works fine, as long as you set the cookie correctly in _advance.php as shown in the documentation for multiple domain.
I actually found a potential work around to this just now, but not sure if it poses security or other blogging issues as I didn't do much testing. There maybe better way to code it, but that's the best I can come up with right now given my limited PHP knowledge.
_basic_config.php
Since the function get_htsrv_url() refers to $baseurl, by changing this:
// -- edit the line or add to end of file -- //
$baseurl = 'http://'.$_SERVER['HTTP_HOST'].'/';
Every time when the script runs, it will automatically checks and sets the $baseurl.
The site 'a.com' would have that $baseurl 'http://a.com/' and 'b.com' would have the $baseurl 'http://b.com/' If you have set up the multiple domains pointing to the same root directory, as suggested by the documentation, then no matter which $baseurl, the files and folders referred with this $baseurl would be under the same location.
_advanced.php
To make sure the cookies are properly set for its respective domains, I needed to take the domain that is currently referred to, and only taking the base domain.
Note: I have assumed that the domain is 'a.com' where the domain name only has two parts 'a' and 'com'. You can adjust to fit your own domain needs. You might need to do matching if you have domains with different roots (such as 'co.jp', 'co.hk', mixing with '.com' etc). You can also just hardcode the match and result since it is basically fixed on your server only. Sub-domains should also work with shared cookies as I'm only taking the base domain.
// -- add to end of file -- //
$temp_domain_array = explode('.',$_SERVER['HTTP_HOST']);
$temp_domain_array_count = count($temp_domain_array);
$cookie_domain = '.'.$temp_domain_array[$temp_domain_array_count - 2].
'.'.$temp_domain_array[$temp_domain_array_count - 1];
$cookie_path = '/';
If there is any issue/problem/better coding for this, let me know so I can learn from it as well.
This will be probably fixed with b2evo 1.9, because the get_htsrv_url() is more intelligent there.
I'm using it also on various subdomains (based on b2evo 1.9) and it works.