• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Tutorial code not working for site_url and some inconsistencies in site_url

I started CodeIgniter recently and found few inconsistencies which I could not understand:

In this page:

It says to use code:


But User guide for same at :

Says to use following code:

Why two different versions?

Now comes my real problem:
$config['base_url'] = 'localhost/ci_host/'; // This was also not mentioned in tutorial.

My relevant code for application/views/news/index.php 
is following:

<?php echo "Base url: ". base_url('news');?>
<?php echo "Site url: ". site_url('news');?>
<?php echo "Slug: ". $news_item['slug'];?>
<p><a href="<?php echo site_url('news/'.$news_item['slug']); ?>">View article</a></p>

And out put for same is: 
Base url: localhost/ci_test/news
Site url: localhost/ci_test/index.php/news
Slug: new_item_1
Base url for slug: localhost/ci_test/news/new_item_1

View article

And "View article" takes me to following link:

But inspect on "View Article" shows following:

<a href="localhost/ci_host/index.php/news/new_item_1">View article</a>

Would be great to take me out of this.

Totally baffling me ...
My codeigniter base is located at: http://localhost/ci_test/

Messages In This Thread
Tutorial code not working for site_url and some inconsistencies in site_url - by bhagwandas - 02-28-2017, 07:18 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.