簡體   English   中英

干凈的URL-從CI中的URL刪除index.php無法正常工作

[英]Clean URL - removing index.php from URL in CI not working

我正在使用CodeIgniter v.3.0.4,無法從URL中刪除“ index.php”。

  1. 我添加了.htaccess文件:

     <ifmodule mod_rewrite.c=""> RewriteEngine On RewriteBase /project_01/ RewriteCond %{REQUEST_URI} ^system.* RewriteRule ^(.*)$ /index.php?/$1 [L] RewriteCond %{REQUEST_URI} ^application.* RewriteRule ^(.*)$ /index.php?/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] </ifmodule> <ifmodule !mod_rewrite.c=""> ErrorDocument 404 /index.php </ifmodule> 
  2. 在應用程序文件夾> config.php>中,將值編輯為:

     $config['index_page'] = ''; 

    和:

     $config['uri_protocol']= 'REQUEST_URI'; 

    和:

     $config['base_url'] = 'http://localhost/Project_01/'; 
  3. 我檢查過我的Apache服務器conf文件在該行旁邊沒有井號:

     LoadModule rewrite_module modules/mod_rewrite.so 

我究竟做錯了什么? 還是我在做什么?

它在CI的先前版本中運行良好,發生了什么變化?

因為您的規則是將請求發送到查詢字符串,所以您需要將QUERY_STRING用於uri_protocol ,而不要使用REQUEST_URI

或者,如果您想保留REQUEST URI ,則可以將規則更改為以下任一選項:

RewriteRule ^(.*)$ index.php/$1 [L]
RewriteRule ^ index.php [L]

暫無
暫無

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

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