0

在试图弄清楚如何让 mod_rewrite 在 xampp 中工作 3 天之后,我终于尝试了 CodeIgniter 论坛。但即使他们也无法给我所需的答案。我在 CI 论坛上的原始帖子可以在这里找到:http ://codeigniter.com/forums/viewthread/221002/

问题是,我确信我做了一切都是为了启用 mod_rewrite:

在 apache/config/httpd.conf 中:取消注释启用 mod_rewrite 模块的那一行。将每一行“AllowOverride None”替换为“AllowOverride All”。

在 CI/application/config/config.php 中:

  • $config['base_url'] = '';
  • $config['index_page'] = '';
  • $config['uri_protocol'] = 'REQUEST_URI';

在 CI/application/config/routes.php 中:

  • $route['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>  

我的网站叫做 Tong-Il,所以当我浏览到 /localhost/Tong-Il/ 时,我得到了我的主页并且一切都加载正常(单独的页眉、页脚和菜单视图 + 到数据库的连接)。但是只要我点击主页上的任何链接,我就会收到 404 错误!

我点击的任何链接都将由“用户”控制器处理。因此,当我在菜单中按“galery”时,我会看到带有以下 URL 的 404 错误页面:localhost/Tong-Il/user/images。当我将其更改为 localhost/Tong-Il/index.php/user/images 它工作正常!我的网站可以在网上找到,但我前一阵子上传了。一切都在网上工作(包括 mod_rewrite),但只是为了给你一个想法:www.tong-il-neeroeteren.be

有没有人可以帮我解决这个问题?

4

1 回答 1

1

您在本地设置了错误的 RewriteBase。代替

RewriteBase /localhost/Tong-Il/

它应该是

RewriteBase /Tong-Il/
于 2012-07-18T21:45:49.153 回答