簡體   English   中英

從Codeigniter .htacceess中刪除“ index.php”

[英]Remove “index.php” from Codeigniter .htacceess

我在Codeigniter工作了幾天,一切進展順利,接受我無法終生擺脫URL中的index.php(從localhost / index.php / controller到localhost / controller) )。

我正在使用CI的默認index.php。

在Apache中啟用了重寫功能。

$config['index_page'] = "";
$config['uri_protocol'] = 'AUTO';

(盡管我嘗試了URI的其他四個設置)

.htaccess看起來像這樣。

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteBase /

  RewriteCond $1 !^(index\.php|resources|robots\.txt)
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]

  <Files "index.php">
    AcceptPathInfo On
  </Files>
</IfModule>

<IfModule !mod_rewrite.c>
  ErrorDocument 404 /index.php
</IfModule>

我在這里這里都嘗試過答案

幫助會很棒

謝謝

附注:如果有問題,我正在子域中工作。

將以下規則放入.htaccess文件,

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]  

如果以上行不起作用,則需要打開CI配置文件application / config / config.php

在那找到以下行

$config['index_page'] = 'index.php';

更改為:

$config['index_page'] = '';

如果還是不行,請嘗試將uri_protocol更改為config中的auto:

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

在.htaccess中,這可能是個問題
RewriteCond $1 !^(indew\\.php|resources|robots\\.txt)
並確保啟用了重寫模塊。 如何為Apache 2.2啟用mod_rewrite
或者對於RewriteRule行,嘗試將其更改為此

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

(index.php之前的/

暫無
暫無

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

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