【发布时间】:2011-02-11 05:54:47
【问题描述】:
我正在使用 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>
有什么建议吗?
【问题讨论】:
-
记得说出你正在尝试什么以及实际发生了什么,而不仅仅是“不起作用”。
标签: .htaccess codeigniter codeigniter-url codeigniter-2