开发者

codeigniter base url not working correctly

开发者 https://www.devze.com 2023-03-28 12:59 出处:网络
I just launched a new site andI have the base url as: $config[\'base_url\']= \'http://x.com/\'; which works but when i go to www.x.com in my browser I get page not found error.

I just launched a new site and I have the base url as:

$config['base_url'] = 'http://x.com/';

which works but when i go to www.x.com in my browser I get page not found error. When I set the base url to 'http://www.x.com/'. Now the site does not work anymore. Does anyo开发者_运维百科ne know how to fix this? I am lost on how to get this going.


It sounds like you actually have an issue with your VirtualHosts. That would explain why you're getting 404's. Try adding this to your httpd.conf or equivalent and then restart Apache:

# Place this in the virtualhost listening to x.com.
ServerAlias www.x.com


Try:

$config['base_url'] = 'http';
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on"){
    $config['base_url'] .= "s";
}
$config['base_url'] .= "://";
if ($_SERVER["SERVER_PORT"]!= "80"){
    $config['base_url'] .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"];
}else{
    $config['base_url'] .= $_SERVER["SERVER_NAME"];
}

$config["base_url"]."/";
0

精彩评论

暂无评论...
验证码 换一张
取 消