2

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?

3
  • application/config/config.php and set your base_url $config['base_url'] Commented Nov 8, 2016 at 5:45
  • 3
    Check this stackoverflow.com/questions/11792268/… Commented Nov 8, 2016 at 5:45
  • 1
    @Dipika You must search related question before asking question a new one. See the link added above by Soliyappan Commented Nov 8, 2016 at 5:51

5 Answers 5

3

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

Sign up to request clarification or add additional context in comments.

Comments

1

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

This is the best and most complete reply since it is the unique one that mentions the URL helper
0

Go to application/config , open config.php and put value in this variable

$config['base_url'] = '';

2 Comments

Ya that's i Know.If i want to configure in localhost then what url I need to pass out??
http ://localhost/yourwebsitename
0

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.

  1. 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.

  1. 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';

  2. Using nginx configuration in Linux or wamp in Windows

    $config['base_url'] = "http://www/your_project_directory/"

Comments

0

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"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.