2012-07-18 37 views
0

經過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

有沒有人可以幫助我解決這個問題?

回答

1

您正在本地設置RewriteBase錯誤。取而代之的

RewriteBase /localhost/Tong-Il/ 

應該

RewriteBase /Tong-Il/ 
+0

我一直在尋找洙長那個愚蠢的錯誤! 非常感謝! – DerpyNerd 2012-07-19 16:11:18