Welcome Guest, Not a member yet? Register   Sign In
Newbie: base_url?
#1

[eluser]ShawnMA[/eluser]
I've searched the forums/web and have been able to find what I assume is a quick and easy answer to my question. I just started working thru the 2 video tutorials and hit a small snag. In tutorial 2 (blog), whenever I attempt to use scaffolding or the comment_insert function my pages always double up the URL so I always get a 404 error. For example: http://localhost/CodeIgniter/index.php/b.../blue/view

I'm developing locally, and have my base_url setting to nothing (""). What do I need to config to ensure my pages always go to the correct location (and don't double up the url)?

Thanks in advance for your time and assistance.
#2

[eluser]John_Betong[/eluser]
Try this, it works fine (for me) on both LOCALHOST and ONLINE Smile

./config/config.php
Code:
$config['base_url'] = 'http://' .$_SERVER['SERVER_NAME'] .'/';
  $config['base_url'] = str_replace('www.','',$config['base_url']);

  $config['site_url'] = $config['base_url'];

  // maybe also define a LOCALHOST constant
  define('LOCALHOST',  'localhost' === $_SERVER['SERVER_NAME']);
  // above can be used in controllers, views, models, libraries, etc
  // in a view
  /*
  if(LOCALHOST)
  {
    echo "<div class='tac btn' style='height:1; margin:4em auto 0em;background:#f00'>";
    echo anchor('blog','blog ', "class='fwb tdn'");
    echo anchor('blog',' show thumbnails');
    echo '</div>';
  }            }
  */
&nbsp;
&nbsp;
&nbsp;




Theme © iAndrew 2016 - Forum software by © MyBB