對於在CodeIgniter網址中刪除index.php的另一個問題,我表示歉意。我已經瀏覽了很多這裏的答案,但一直無法解決我的問題。Codeigniter:刪除index.php只能使用較少的uri段。爲什麼?
目前,我有我的本地開發服務器設置,使
http://localhost/project/index.php/controller/function/page
和http://localhost/project/page
兩個負載頁預期。
但是,如果我嘗試加載page/subpage
只有版本index.php
作品:
http://localhost/project/index.php/controller/function/page/subpage
(作品)http://localhost/project/page/subpage
(不工作)
第二個不調用我的控制器,但會產生一個CodeIgniter 404錯誤頁面。這讓我懷疑問題出在我的.htaccess
文件中,但我不知道。我不太瞭解.htaccess
文件。
我.htaccess
文件包含
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]enter code here
我已經嘗試了各種排列組合,人們已經建議對其他類似的問題,但他們都沒有任何影響,只是一個它生產的通用PHP 404頁,而不是CodeIgniter之一。
我能做些什麼不同,以得到http://localhost/project/page/subpage
加載?
我routes.php
文件包含:
$route['default_controller'] = 'Controller';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;
$route['(:any)'] = 'controller/index/$1';
我config.php
文件包含:
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
是否還有其他設置,將是有益的,我張貼?
這是什麼'$ route ['(:any)'] ='controller/index/$ 1';'?這是否合理?這也與默認控制器一樣... –
@AbdullaNilam它在那裏,以便我可以加載http:// localhost/project/page /。沒有這一行,默認的控制器加載http:// localhost/project /的主頁,但是我得到了http:// localhost/project/page /的404錯誤。也許我可以在那裏使用更好的東西,但是如果我知道我會使用它。有什麼建議麼? – Mehmet