CI 2.0控制器/功能访问不起作用

时间:2011-02-11 05:54:47

标签: .htaccess codeigniter codeigniter-url codeigniter-2

我正在使用CI构建一个网站,我希望我的网站URI是干净的

http://myweb.com/controller/function

没有'index.php'部分。

我使用CI 1.73成功完成了这项工作,但我无法使用CI 2.0 我已将route.php设置为:

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

和config.php

$config['index_page'] = '';

我还使用CI 1.73

放置了我的试用版中的.htaccess文件
<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>

任何建议?

1 个答案:

答案 0 :(得分:2)

我会说这句话RewriteBase /myweb是罪魁祸首。请尝试改为RewriteBase /

此外,我会尽量简化你的.htaccess直到你让它工作,这样的事情:

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

请注意,我认为你应该在index.php之后只放一个/,而不是?/这样:

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