.htaccess中没有重新路由[codeIgniter] [英] HTaccess not rerouting [CodeIgniter]
问题描述
我有使用完整的URL时的伟大工程的应用程序:sitename.com/index.php/foo/但是当我使用的.htaccess删除的index.php它似乎并没有正常工作。不管我访问该页面我只看到主页。 htaccess的文件做一些事情,因为如果没有这一行,我收到了404错误。
I have an application that works great when using the full url: sitename.com/index.php/foo/ but when I use HTaccess to remove the index.php it doesn't seem to work as expected. No matter which page I access I only see the home page. The htaccess file is doing something because without that line I get a 404 error.
RewriteEngine on
RewriteCond $1 !^(index\.php|assets|file-manager-files|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]
思考?
在我的测试网站一切正常就好了。这是一个需要调整服务器设置?
On my test site everything works just fine. Is this a server setting that needs to be tweaked?
推荐答案
使用codeigniter你想要的东西是这样的:
With Codeigniter you want something like this:
<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>
如果不工作,检查以确保 $配置['index_page'] ='';
和你的.htaccess指令设置正确的:
If that is not working, check to make sure $config['index_page'] = '';
and your .htaccess directives are set right:
<Directory "/some/absolute/path/htdocs">
Options Indexes Includes FollowSymLinks MultiViews
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
我已经做了数以百计的codeigniter安装在许多操作系统的configs并一直能得到这个工作,但我有一些问题,偶尔,我必须发挥创意,以获取的index.php
消失。
这篇关于.htaccess中没有重新路由[codeIgniter]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!