[英]codeigniter base url not working correctly
I just launched a new site and I have the base url as:我刚刚启动了一个新站点,我的基础 url 为:
$config['base_url'] = ' http://x.com/ ';
$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.这有效,但是当我在浏览器中从 go 到 www.x.com 时,我得到页面未找到错误。 When I set the base url to ' http://www.x.com/ '.
当我将基础 url 设置为“ http://www.x.com/ ”时。 Now the site does not work anymore.
现在该网站不再工作了。 Does anyone know how to fix this?
有谁知道如何解决这一问题? I am lost on how to get this going.
我不知道如何进行下去。
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"]."/";
It sounds like you actually have an issue with your VirtualHost
s .听起来您实际上对
VirtualHost
有问题。 That would explain why you're getting 404's.这可以解释为什么你会得到 404。 Try adding this to your httpd.conf or equivalent and then restart Apache:
尝试将此添加到您的 httpd.conf 或等效项,然后重新启动 Apache:
# Place this in the virtualhost listening to x.com.
ServerAlias www.x.com
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.