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 VirtualHost
s. 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"]."/";
精彩评论