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?

- 6,775
- 11
- 53
- 79

- 115
- 1
- 3
- 15
-
`application/config/config.php` and set your base_url `$config['base_url']` – Razib Al Mamun Nov 08 '16 at 05:45
-
3Check this http://stackoverflow.com/questions/11792268/how-to-set-proper-codeigniter-base-url – Soliyappan Nov 08 '16 at 05:45
-
1@Dipika You must search related question before asking question a new one. See the link added above by **Soliyappan** – Choxx Nov 08 '16 at 05:51
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

- 729
- 7
- 10
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";

- 25,704
- 4
- 40
- 59
-
This is the best and most complete reply since it is the unique one that mentions the URL helper – Robert Feb 16 '19 at 09:32
Go to application/config , open config.php and put value in this variable
$config['base_url'] = '';

- 1,229
- 11
- 17
-
Ya that's i Know.If i want to configure in localhost then what url I need to pass out?? – Dipika Nov 08 '16 at 05:51
-
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/"

- 1,119
- 11
- 23
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']=""; or you can also set $config['base_url']="http://host/yoursite"

- 17
- 1
- 5