[英]How to set config_base url in config.php file in codeigniter?
I am beginner in Codeigniter
. 我是
Codeigniter
初学者。 I have downloaded the software and tried to configure it. 我已经下载了该软件并尝试对其进行配置。 How can I configure a base url to use in codeigniter?
如何配置要在Codeigniter中使用的基本URL?
You should got to this file path 您应该转到此文件路径
Codeigniter/applications/config/config.php 笨/应用/配置/ config.php文件
Search for this line that contains 搜索包含以下内容的行
$config['base_url'] = ""
Then your base_url should be 然后您的base_url应该是
$config['base_url'] = "http://yoursite.com/"
If xampp, it should be 如果是xampp,应该是
$config['base_url'] = "http://localhost/yoursite/"
And if wamp, it should be 如果是沼泽,应该
$config['base_url'] = "http://www/yoursite/"
Note that yoursite is the filename of the site folder you have in htdocs or www folder 注意yoursite是您在htdocs或www文件夹中的站点文件夹的文件名
When you make use of <?php echo base_url(directory/file_name); ?>
当您使用
<?php echo base_url(directory/file_name); ?>
<?php echo base_url(directory/file_name); ?>
In your views, it should output something like: <?php echo base_url(directory/file_name); ?>
在您的看法,它应该输出是这样的:
"http://localhost/yoursite.com/directory/file_name"
That should do the trick 这应该够了吧
Base URL should be absolute, including the protocol: 基本URL应该是绝对的,包括协议:
$config['base_url'] = "http://somesite.com/somedir/";
If using the URL helper, then base_url()
will output the above string. 如果使用URL帮助器,则
base_url()
将输出上述字符串。
Passing arguments to base_url()
or site_url()
will result in the following assuming 将参数传递给
base_url()
或site_url()
将导致以下假设
$config['index_page'] = "index.php";
Note: Following solutions is detailed provided you have setup your localhost on your machine successfully. 注意:详细说明了以下解决方案,前提是您已成功在计算机上设置了本地主机 。
Both the points as mentioned above will work. 如上所述的两点都将起作用。 Like, you can set the Base URL value for your corresponding setting of localhost or you can set it to EMPTY .
例如,您可以为相应的localhost设置Base URL值,也可以将其设置为EMPTY 。
Setting as Empty ( Simple and Elegant ) 设置为空( 简洁大方 )
$config['base_url'] = '';
$ config ['base_url'] ='';
The Codeigniter version 2.0.0.0 simply autodetects the base_url of your current project. Codeigniter版本2.0.0.0只是自动检测当前项目的base_url。
But in CI version 3.0.0.0 it's NOT supported anymore. 但在CI版本3.0.0.0它不支持了。 You have to explicitly declare you projects Base URL.
您必须明确声明您的项目基本URL。
Configuring the path to your Project Directory. 配置项目目录的路径。 The following procedure is when you setup your localhost using xampp in Windows or using default Apache's configuration folder in Linux ie var/www/html/your_project_directory .
以下过程是在Windows中使用xampp或Linux中使用默认Apache的配置文件夹(即var / www / html / your_project_directory)设置本地主机时。
$config['base_url'] = ' http://localhost/your_project_directory ';
$ config ['base_url'] =' http:// localhost / your_project_directory ';
Using nginx configuration in Linux or wamp in Windows 在Linux中使用Nginx配置或在Windows中使用Wamp
$config['base_url'] = " http://www/your_project_directory/ "
$ config ['base_url'] =“ http:// www / your_project_directory / ”
转到application / config,打开config.php并将值放在此变量中
$config['base_url'] = '';
if you are running your project in local-server like Xamp or wamp then you can set the base url like this $config['base_url']=""; 如果您正在Xamp或wamp等本地服务器中运行项目,则可以像$ config ['base_url'] =“”这样设置基本URL。 or you can also set $config['base_url']="http://host/yoursite"
或者,您也可以设置$ config ['base_url'] =“ http:// host / yoursite”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.