title: CodeIgniter Tutorial Error on Form Submit
body: <p>Okay, so I just started learning CodeIgniter last night and I'm just about to finish the final part of the tutorial today, however, i get a 404 page not found error whenever i click the submit button. </p>
  
  <p>Here is the last part of the tutorial where it tells you to create a form and store the data to the database: <a href="http://www.codeigniter.com/user_guide/tutorial/create_news_items.html" rel="nofollow noreferrer">http://www.codeigniter.com/user_guide/tutorial/create_news_items.html</a></p>
  
  <p>My URL for the form is <a href="http://localhost/ci/index.php/news/create" rel="nofollow noreferrer">http://localhost/ci/index.php/news/create</a></p>
  
  <p>but then when I clicked the submit button, the URL turns to <a href="http://localhost/ci/index.php/news/localhost/ci/index.php/news/create" rel="nofollow noreferrer">http://localhost/ci/index.php/news/localhost/ci/index.php/news/create</a></p>
  
  <p><a href="https://i.stack.imgur.com/8Un8h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8Un8h.png" alt="enter image description here"></a></p>
  
  <p>weird, i know theres a problem with the routing but I don't know the specific ones.</p>
  
  <p>Here's my Route file:</p>
  
  <pre><code>$route['news/create'] = 'news/create';
  $route['news/(:any)'] = 'news/view/$1';
  $route['news'] = 'news';
  $route['(:any)'] = 'pages/view/$1';
  $route['default_controller'] = 'pages/view';
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>class News extends CI_Controller{
  public function __construct(){
      parent::__construct();
      $this-&gt;load-&gt;model('news_model');
      $this-&gt;load-&gt;helper('url_helper');
  }
  
  public function index(){
      $data['news'] = $this-&gt;news_model-&gt;get_news();
      $data['title'] = 'News archive';
  
      $this-&gt;load-&gt;view('templates/header',$data);
      $this-&gt;load-&gt;view('news/index',$data);
      $this-&gt;load-&gt;view('templates/footer',$data);
  }
  
  public function view($slug = NULL){
      $data['news_item'] = $this-&gt;news_model-&gt;get_news($slug);
  
      if(empty($data['news_item'])){
          show_404();
      }
  
      $data['title'] = $data['news_item']['title'];
  
      $this-&gt;load-&gt;view('templates/header', $data);
      $this-&gt;load-&gt;view('news/view', $data);
      $this-&gt;load-&gt;view('templates/footer');
  }
  
  public function create(){
      $this-&gt;load-&gt;helper('form');
      $this-&gt;load-&gt;library('form_validation');
  
      $data['title'] = 'Create a news item';
  
      $this-&gt;form_validation-&gt;set_rules('title','Title','required');
      $this-&gt;form_validation-&gt;set_rules('text','Text','required');
  
      if($this-&gt;form_validation-&gt;run() === FALSE){
          $this-&gt;load-&gt;view('templates/header',$data);
          $this-&gt;load-&gt;view('news/create');
          $this-&gt;load-&gt;view('templates/footer');
      }
      else{
          $this-&gt;news_model-&gt;set_news();
          $this-&gt;load-&gt;view('news/success');
      }
  }}
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>class News_model extends CI_Model{
  public function __construct(){
      $this-&gt;load-&gt;database();
  }
  
  public function get_news($slug = FALSE){
      if($slug === FALSE){
          $query = $this-&gt;db-&gt;get('news');
          return $query-&gt;result_array();
      }
  
      $query = $this-&gt;db-&gt;get_where('news',array('slug'=&gt;$slug));
      return $query-&gt;row_array();
  }
  
  public function set_news(){
      $this-&gt;load-&gt;helper('url');
  
      $slug = url_title($this-&gt;input-&gt;post('title'),'dash',TRUE);
  
      $data = array(
          'title' =&gt; $this-&gt;input-&gt;post('title'),
          'slug' =&gt; $slug,
          'text' =&gt; $this-&gt;input-&gt;post('text')
      );
  
      return $this-&gt;db-&gt;insert('news',$data);
  }}
  </code></pre>
  
  <p>Form:</p>
  
  <p><a href="https://i.stack.imgur.com/cJ6nh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cJ6nh.png" alt="enter image description here"></a></p>