0

what i'm trying to do is to remove the index.php file in my urls in CodeIgniter following this documentation:

http://www.codeigniter.com/userguide3/general/urls.html#removing-the-index-php-file

I wrote .htaccess file with thid code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

But when i try to access the url: http://127.0.0.1/my-site/admin, this is redirected to http://127.0.0.1/dashboard

This is my base_url config:

$config['base_url'] = 'http://127.0.0.1/my-site';

And this is routes.php file:

$route['default_controller'] = 'home'; 
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['admin']='admin/index'; 
$route['admin/login']='admin/login';

Any help would be appreciated!

bobc82
  • 497
  • 7
  • 17
  • Make sure .htaccess is working or not in your localhost setup. Follow the instructions [here](http://stackoverflow.com/questions/17162214/htaccess-not-working-on-localhost-with-xampp#answer-17164484)... – d.coder Nov 07 '16 at 10:07
  • Put a slash at the end of base url. – Tpojka Nov 07 '16 at 10:54
  • One question how the dashboard in the url came from? Do you have any controller with named dashboard – Vivek Shah Nov 07 '16 at 11:36

3 Answers3

0

try this one

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
BIBIN JOHN
  • 354
  • 7
  • 13
0

if your using wamp Server left click tray

icon->Apache->Apache modules->and find and click on rewrite_module

Reuben Gomes
  • 878
  • 9
  • 16
0

Firstly, ensure that your .htaccess file is working (loaded by Apache/PHP)

To test this, open your .htaccess file and type some junk text (eg. testing..) and save the file.

Now load your application's home page. (eg. http://localhost/mywebapp/)

If you get an 'Internal Server Error' then it means your .htaccess file is working. Else if the default page is loading, then it means your .htaccess file is not loading.

If your .htaccess file is not working then, it is due to the Apache config issue.

  1. Open Apache config file (typically C:\Apache\conf\httpd.conf)

  2. Search for word 'AllowOverride'.

  3. Change values of all the instances from

AllowOverride None

to

AllowOverride All

  1. Save Apache config file.

  2. Restart Apache Service/Server.

This should solve your redirection issue.