Welcome Guest, Not a member yet? Register   Sign In
2 domainnames for 1 website base_url questoin
#1

[eluser]woony[/eluser]
Hi,
I just developped a website in codeigniter.
1 webspace, 2 domainnames...
now for my hosting this is no problem, both urls go to the same ip, so either url works.

Now my problem is... I often use base_url(), so I was wondering if anyone knows a way to have for my base_url a.com when I visit the site from a.com and b.com when I visit from b.com
..
thanks in advance.
#2

[eluser]Kamarg[/eluser]
Taken from an excellent post somewhere on these forums that I can't seem to find anymore. In config.php
Code:
if(isset($_SERVER['HTTP_HOST'])) {
    $config['base_url'] = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http';
    $config['base_url'] .= '://'. $_SERVER['HTTP_HOST'];
    $config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
}
#3

[eluser]woony[/eluser]
[quote author="Kamarg" date="1267661254"]Taken from an excellent post somewhere on these forums that I can't seem to find anymore. In config.php
Code:
if(isset($_SERVER['HTTP_HOST'])) {
    $config['base_url'] = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http';
    $config['base_url'] .= '://'. $_SERVER['HTTP_HOST'];
    $config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
}
[/quote]

works like a charm!
thank you very much.
#4

[eluser]Unknown[/eluser]
i also try this.




Theme © iAndrew 2016 - Forum software by © MyBB