CodeIgniter - Simple base_url question
I think your problem is that base_url is a function in ci 2+ so try this instead
<link href="<?php echo base_url() ?>css/style.css"
rel="stylesheet" type="text/css" />
It depends how you defined base_url if you did an ending slash otherwise just add a slash so
/css/style.css
How to set proper codeigniter base url?
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";
:
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
base_url() function not working in codeigniter
In order to use base_url()
, you must first have the URL Helper loaded. This can be done either in application/config/autoload.php
(on or around line 67):
$autoload['helper'] = array('url');
Or, manually:
$this->load->helper('url');
Once it's loaded, be sure to keep in mind that base_url()
doesn't implicitly print or echo out anything, rather it returns the value to be printed:
echo base_url();
Remember also that the value returned is the site's base url as provided in the config file. CodeIgniter will accomodate an empty value in the config file as well:
If this (base_url) is not set then CodeIgniter will guess the protocol, domain and path to your installation.
application/config/config.php, line 13
Codeigniter base_url() in whack?
CodeIgniter automatically adds the base_url to the action of the form when you use the form helper.
For example, you can use:
<?=form_open('main/login'); ?>
which will produce:
http//example.com/main/login
And a correct URL! Pretty simple! :D
More information at:
http://codeigniter.com/user_guide/helpers/form_helper.html
Codeigniter: Base_url doesn't seem to be working
I am on the grid as well. After re-reading your question and doing a little testing (it works for me), I think what's happening is you forgot to load the url
helper.
If you want the sites base url available to you to use in the application via base_url()
, you need to load the url
helper first. Either via config/autoload.php or load it manually in your controller.
Otherwise you could use config/constants.php to define constant variables:
define('BASE_URL', 'http://site.com');
define('BASE_PATH', '/path/to/CI/folder');
codeigniter using the name of controller in base url
this is happen when you don't echo base URL only (echo) is missing thanks to all for ans
How can I make part of base_url in codeigniter as a dynamic one?
This should include the footer image dynamically inside your code:
<?php echo base_url('assets/images/' . $footer->image); ?>
The dot operator concatenates two strings.
Related Topics
Clip-Path:Circle() Radius Doesn't Seem to Be Calculated Correctly
Why Border of <Tr> Not Showing in Ie
CSS Font Differences Between Browsers
Overriding Placeholder Font CSS in All Browsers
Css-Grid: Bleed Background Outside Container
Achieving This Hr Element with CSS Styling - Pseudo Elements
How to Draw a Trapezoid-Like Card
Lighten the Background Colour from Another Class
Codeigniter - Simple Base_Url Question
How to Do Browser Specific Conditional CSS Inside a *.CSS File
Galaxy S4 Stock Browser CSS3 Border-Radius Support
Bootstrap 4.1 - to Get Grid System Only
CSS Overlapping Elements & Opacity Issue
How to Target CSS3 Columns Individually with Selectors