经过3天的尝试弄清楚如何让mod_rewrite在xampp中工作,我终于尝试了CodeIgniter论坛。但即使他们不能给我我需要的答案。 我的CI论坛原帖可以在这里找到:http://codeigniter.com/forums/viewthread/221002/CodeIgniter:在Xampp Mod_Rewrite
的问题是,我相信我所做的一切都是为了使mod_rewrite的:
在阿帕奇/配置/ httpd.conf中: 取消注释说一行启用了mod_rewrite模块。 用“AllowOverride All”替换每一行“AllowOverride None”。
在CI /应用/配置/ config.php中:
- $配置[ 'BASE_URL'] = '';
- $ config ['index_page'] ='';
- $ config ['uri_protocol'] ='REQUEST_URI';
在CI /应用/配置/ routes.php文件:
- $路线[ 'default_controller'] = “用户”;
我的.htaccess文件位于可找到应用程序文件夹的相同文件夹中。 .htaccess文件看起来是这样的:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /localhost/Tong-Il/
#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]
php_flag short_open_tag off
php_flag magic_quotes_gpc Off
</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>
我的网站被称为塘-11,所以当我浏览到/本地主机/佟-11 /,我得到我的主页,一切都加载罚款(单独的页眉,页脚和菜单视图+连接到数据库)。但只要我点击主页上任何地方的链接,我就会收到404错误!
我点击的任何链接都将由“用户”控制器处理。所以当我在菜单中按下“galery”时,我得到了404错误页面:localhost/Tong-Il/user/images。 当我将其更改为localhost/Tong-Il/index.php/user/images时,它工作正常! 我的网站可以在网上找到,但我上传了一段时间。一切工作在线(包括mod_rewrite),但只是给你一个想法:www.tong-il-neeroeteren.be
有没有人可以帮助我解决这个问题?
我一直在寻找洙长那个愚蠢的错误! 非常感谢! – DerpyNerd 2012-07-19 16:11:18