如何设置正确的codeigniter基本网址? [英] How to set proper codeigniter base url?

查看:36
本文介绍了如何设置正确的codeigniter基本网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的网站在开发环境中时 - 它是网址:testurl.com

when I had my site on development environment - it was url: testurl.com

现在在生产服务器上,我的 codeigniter 应用程序的地址必须是 someurl.com/mysite/

Now on production server my codeigniter app's address has to be someurl.com/mysite/

我将它移到那里,每次我尝试运行某个函数时,例如 /home/test - 它都会让我进入 someurl.com/home/test- 这是错误的.

I moved it there, and everytime I'm trying to run some function, example /home/test - it gets me into someurl.com/home/test - which is WRONG.

它必须是 someurl.com/mysite/home/test - 如何修复它?我确实设置了

It has to be someurl.com/mysite/home/test - How to fix it? I did set

$config['base_url'] = someurl.com/mysite/

推荐答案

Base URL 应该是绝对的,包括协议:

Base URL should be absolute, including the protocol:

$config['base_url'] = "http://somesite.com/somedir/";

如果使用 URL helper,则 base_url() 将输出上述字符串.

If using the URL helper, then base_url() will output the above string.

将参数传递给 base_url()site_url() 将导致以下结果(假设 $config['index_page'] = "index.php";:

Passing arguments to base_url() or site_url() will result in the following (assuming $config['index_page'] = "index.php";:

echo base_url('assets/stylesheet.css'); // http://somesite.com/somedir/assets/stylesheet.css
echo site_url('mycontroller/mymethod'); // http://somesite.com/somedir/index.php/mycontroller/mymethod

这篇关于如何设置正确的codeigniter基本网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆