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

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

问题描述

当我在开发环境中使用我的网站时,它是网址: 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 should be absolute, including the protocol:

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

如果使用URL帮助程序,则 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 base url?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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