簡體   English   中英

CodeIgniter:Xampp上的Mod_Rewrite

[英]CodeIgniter: Mod_Rewrite on Xampp

經過三天的嘗試弄清楚如何在xampp中使用mod_rewrite,我終於嘗試了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錯誤!

我單擊的任何鏈接都將由“用戶”控制器處理。 因此,當我在菜單中按“畫廊”時,出現以下URL的404錯誤頁面:localhost / Tong-Il / user / images。 當我將其更改為localhost / Tong-Il / index.php / user / images時,它工作正常! 我的網站可以在網上找到,但是我前一段時間上傳了它。 一切都可以在線工作(包括mod_rewrite),但是只是為了給您一個想法:www.tong-il-neeroeteren.be

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

您在本地將RewriteBase設置為錯誤。 代替

RewriteBase /localhost/Tong-Il/

它應該是

RewriteBase /Tong-Il/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM