簡體   English   中英

在本地刪除codeigniter的index.php

[英]Removing index.php of codeigniter on local

我正在嘗試刪除本地主機中的index.php,但它似乎不起作用,它位於http://localhost/testing

我將.htacces放在htdocs下的“測試”目錄中。

Apache / conf上的LoadModule rewrite_module modules/mod_rewrite.so也已取消選中。

這是我的.htaccess:

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

這是我的配置:

$config['base_url']    = "http://localhost/testing";
$config['index_page'] = '';
$config['uri_protocol'] = 'AUTO';

當我訪問登錄控制器時,找不到它。

未找到

在此服務器上找不到請求的URL / testing / login。

我真的不知道下一步該怎么做。 任何幫助,將不勝感激。

嘗試這個 :-

Config.php:-

$config['base_url'] = 'http://localhost/testing/';

$config['index_page'] = '';

.htaccess

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

基本上index.php包含在所有URL中:

我們可以通過簡單的規則使用.htaccess刪除它。 以下是使用“負”方法進行重定向的所有文件的示例,

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

現在重新啟動服務器並檢查

您的htaccess應該像

RewriteEngine On
RewriteBase /testing/

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

無需附加/testing/因為RewriteBase已經解決了這一問題。

RewriteBase的結尾斜杠:

RewriteEngine On
RewriteBase /testing

RewriteCond $1 !^(index\.php|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

$config['base_url']應該為http://localhost/testing/

$config['index_page']應為空白。

在.htaccess文件中嘗試以下一項:

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

您的配置文件很好

區別在於“?” 在index.php之后

您可能還想嘗試在./application/config/config.php中更改$config['uri_protocol']的值。 有時CodeIgniter會弄錯它。 將其更改為PATH_INFO可能有效。

暫無
暫無

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

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