0

我正在使用 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>

有什么建议吗?

4

1 回答 1

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]
于 2011-02-11T09:16:30.727 回答