0

I want to remove index.php to access my controllers directly. However, I cannot directly go my controller. I have to use index.php. For example: I want to go http://example.com/my_controller/method instead of http://example.com/index.php/my_controller/method

By the way, I used my test server, not local server like XAMPP. I enabled apache mod rewrite in my server.

I tried a lot of htaccess rules, conditions but I cannot work it. Please help me!

This is my .htaccess file:

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

my config.php:

$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

How can I go directly?

Sevki Kocadag
  • 172
  • 5
  • 20

2 Answers2

1

How about verifying that mod_rewrite is actually enabled. You could follow the instructions here: How to check whether mod_rewrite is enable on server?

Community
  • 1
  • 1
plhyhc
  • 121
  • 1
  • 6
  • Yes, I checked and it is enabled. The image link is http://pasteboard.co/P513xT9.png – Sevki Kocadag Jan 15 '16 at 23:44
  • How about removing the If statement... – plhyhc Jan 15 '16 at 23:52
  • How about testing rewrite by following these instructions to intentionally to get HTTP 500 error. That should prove it is working. http://stackoverflow.com/questions/9234289/verify-if-htaccess-file-is-running – plhyhc Jan 17 '16 at 02:57
0

Try this code in your .htaccess file

RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php/$1 [L]
sasy
  • 443
  • 2
  • 9
  • 21