htaccess代码:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
配置文件:
$config['base_url'] = 'http://baseurl/apps';
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';
$config['enable_hooks'] = FALSE;
$config['allow_get_array'] = TRUE;
$config['enable_query_strings'] = FALSE;
我得到了"404页找不到"错误来了。当我更改htaccess文件时
RewriteRule ^(.*)$ index.php?/$1 [L] to RewriteRule ^(.*)$ index.php/$1 [L]
出现"未指定输入文件"错误。
我已经尝试了几个htaccess代码,但仍然遇到这些问题。
我使用上面的htaccess代码,从url中删除index.php。
尝试设置
RewriteBase /apps/
在.htaccess文件中
一般来说,我使用这个htaccess,它从未让我失望:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
#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 %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
还不能使用注释,所以我使用了答案框。你可能想看看这个问题,它已经解决了,看起来几乎和你的问题完全一样:CodeIgniter htaccess和URL重写问题
edit:如果您使用的是nginx或其他Web服务器,请记住这些服务器不支持.htaccess文件。我有时也会在一些应用程序的nginx中出现"未指定文件输入"错误。大多数情况下是这样,因为这些服务器不支持.htaccess文件。所以,请确保您使用的是Apache。