CI 2.0 controller/function access not working

552 Views Asked by At

I am building a website using CI, and I want my website URI to be clean as

http://myweb.com/controller/function

without 'index.php' part.

I have succeed in doing this with CI 1.73, but i can't get it working with CI 2.0
I have set route.php to be:

$route['default_controller'] = 'home';

and config.php

$config['index_page'] = '';

i also have put the .htaccess file that was working in my trial using CI 1.73

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /myweb

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond $1 !^(index\.php|images|captcha|css|js|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

any suggestion ?

1

There are 1 best solutions below

0
On BEST ANSWER

I'd say this line RewriteBase /myweb is the culprit. Try putting RewriteBase / instead.

Also, I would try simplifying your .htaccess at the maximum until you get it to work, something like this:

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

Note that I think you should put just a / after index.php, not ?/ like so:

RewriteRule ^(.*)$ index.php/$1 [L]