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。
答案 0 :(得分:0)
暂时无法使用评论,因此请使用答案框。你可能想看看这个问题,这个问题已经解决了,看起来几乎与你的问题完全相同:CodeIgniter htaccess and URL rewrite issues
编辑:如果您使用的是nginx或其他网络服务器,请记住这些服务器不支持.htaccess文件。我有时也会在某些应用程序中获得nginx中的'文件输入未指定'错误。主要是因为那些服务器不支持.htaccess文件。所以,请确保您使用的是Apache。
答案 1 :(得分:0)
尝试设置
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>