I am beginner in Codeigniter.
I have downloaded the software and tried to configure it. How can I configure a base url to use in codeigniter?
5 Answers
You should got to this file path
Codeigniter/applications/config/config.php
Search for this line that contains
$config['base_url'] = ""
Then your base_url should be
$config['base_url'] = "http://yoursite.com/"
If xampp, it should be
$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
When you make use of <?php echo base_url(directory/file_name); ?> In your views, it should output something like:
"http://localhost/yoursite.com/directory/file_name"
That should do the trick
Comments
Base URL should be absolute, including the protocol:
$config['base_url'] = "http://somesite.com/somedir/";
If using the URL helper, then base_url() will output the above string.
Passing arguments to base_url() or site_url() will result in the following assuming
$config['index_page'] = "index.php";
1 Comment
Go to application/config , open config.php and put value in this variable
$config['base_url'] = '';
2 Comments
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.
Setting as Empty (Simple and Elegant)
$config['base_url'] = '';
The Codeigniter version 2.0.0.0 simply autodetects the base_url of your current project.
But in CI version 3.0.0.0 it's NOT supported anymore. You have to explicitly declare you projects Base 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 i.e var/www/html/your_project_directory.
$config['base_url'] = 'http://localhost/your_project_directory';
Using nginx configuration in Linux or wamp in Windows
$config['base_url'] = "http://www/your_project_directory/"
application/config/config.phpand set your base_url$config['base_url']