CodeIgniter htaccess redirect url issues

I want "nice urls" for my website. I'm looking at using .htaccess and I have tried many versions.

Now I have this:

IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
# !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
#  slashes.
# If your page resides at
# then use
# RewriteBase /mysite
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

<IfModule !mod_rewrite.c>
 # If we don't have mod_rewrite installed, all 404's
 # can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin

ErrorDocument 404 /index.php

So this removes index.php from the URL. At first it was ok, but

Here is my config.php:

$config['base_url'] = 'localhost/mysite/';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

And my .htaccess file is in my app root. folder img

I need a login for admin page, so localhost/mysite/admin is the my url for admin site.

public function index()
    //  $this->session->unset_userdata('logged_in'); session_destroy();
        $data['sitename']="Varkocs Old Pub";
             $session_data = $this->session->userdata('logged_in');
             $data['username'] = $session_data['username'];
             $this->load->view('admin/home_view', $data);
         //If no session, redirect to login page
         //redirect('login', 'refresh');

            $this->load->helper(array('form', 'url'));


public function logout()
   redirect('', 'refresh');

This is my admin controller. I try here if logged in I load home_view, else the login view.

<div id="" class="container-fluid ">
    <div id="" class="row">
        <div id="" class="col-md-4 text-center admin_container">

          <h2><?php echo $sitename;?><h4>belépés az admin felületre</h4></h2>

           <?php  echo validation_errors('<p class="bg-danger">','</p>');?>

           <form action="verifylogin" method="post" accept-charset="utf-8">
            <div class="form-group">
             <label for="username">Username:</label>
             <input class="form-control" placeholder="" type="text" size="20" id="username" name="username"/>
            <div class="form-group">
             <label for="password">Password:</label>
             <input class="form-control" placeholder="password" type="password" size="20" id="passowrd" name="password"/>
             <input class="btn btn-warning btn-lg btn-block" type="submit" value="Login"/>

This is the login view. I can't use here:

echo form_open('verifylogin');

Because it's returning the wrong URL.

So I write HTML:

<form action="verifylogin" method="post" accept-charset="utf-8">

The form validation with CodeIgniter is working. But the redirect afterwards doesn't work.

  $this->load->helper(array('form', 'url'));
   if($this->form_validation->run() == FALSE)
     //Field validation failed.  User redirected to login page
    $data['sitename']="Varkocs Old Pub";


     //Go to private area
     redirect('admin', 'refresh');


I have tried many ways to fix this, but I failed.


The Codeigniter documentation says the following about the redirect function:

In order for this function to work it must be used before anything is outputted to the 
browser since it utilizes server headers.

This rule can be tricky to follow. A space or line end before the opening PHP tag will already break it.

Need Your Help

fill month gaps

mysql database date

I need to fill the gap with 0 if no order occurred in a month.

jQuery file upload - get the "Open" event from the dialog window

jquery file-upload dialog

Does anyone know how can I find out when the "Open" button was clicked in the dialog window of the file upload?