当我的网站在开发环境中时 - 它是url:testurl.com
现在在生产服务器上我的codeigniter应用程序的地址必须是someurl.com/mysite/
我把它移到那里,每次我试图运行一些功能,例如/ home/test - 它让我进入someurl.com/home/test - 这是错误的.
它必须是someurl.com/mysite/home/test - 如何解决?我确实设定了
$config['base_url'] = someurl.com/mysite/
Run Code Online (Sandbox Code Playgroud)
Bre*_*dan 61
基本URL应该是绝对的,包括协议:
$config['base_url'] = "http://somesite.com/somedir/";
Run Code Online (Sandbox Code Playgroud)
如果使用URL帮助器,base_url()则会输出上面的字符串.
传递参数base_url()或site_url()将导致以下结果(假设$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
Run Code Online (Sandbox Code Playgroud)
小智 20
校验
config> config
codeigniter文件结构
更换
$config['base_url'] = "your Website url";
Run Code Online (Sandbox Code Playgroud)
同
$config['base_url'] = "http://".$_SERVER['HTTP_HOST'];
$config['base_url'] .= preg_replace('@/+$@', '', dirname($_SERVER['SCRIPT_NAME'])).'/';
Run Code Online (Sandbox Code Playgroud)
Nee*_*ngh 10
嗯,这很有趣,这是快速和有效的代码:
index.php
/**
* Define APP_URL Dynamically
* Write this at the bottom of index.php
*
* Automatic base url
*/
define('APP_URL', ($_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http') . "://{$_SERVER['SERVER_NAME']}".str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']));
Run Code Online (Sandbox Code Playgroud)
config.php
/*
|--------------------------------------------------------------------------
| Base Site URL
|--------------------------------------------------------------------------
|
| URL to your CodeIgniter root. Typically this will be your base URL,
| WITH a trailing slash:
|
| http://example.com/
|
| If this is not set then CodeIgniter will guess the protocol, domain and
| path to your installation.
|
*/
$config['base_url'] = APP_URL;
Run Code Online (Sandbox Code Playgroud)
CodeIgniter ROCKS !!! :)
| 归档时间: |
|
| 查看次数: |
192955 次 |
| 最近记录: |