簡體   English   中英

routes.php中的CodeIgniter路由鏈接

[英]CodeIgniter routing link in routes.php

當我嘗試從localhost/admin路由到localhost/index.php/admin時,我很困惑

localhost/index.php/admin - 此鏈接正常工作。

我試過了:

$route['admin'] = 'index.php/admin';
$route['default_controller'] = 'front';

localhost/index.php/front工作正常,當我打開localhost它顯示無效的首頁。

我在這個例子中使用CodeIgniter HMVC。

我添加了額外的代碼,因為它不允許我發布問題。

因為您需要刪除URL中的index.php

轉到config / config.php

$config['base_url'] = 'http://localhost/projectname/';
$config['index_page'] = ''; # remove index.php on here

.htaccess中 - 放在應用程序文件夾之外。

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule .* index.php/$0 [PT,L]
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

並在routes.php

刪除此$route['admin'] = 'index.php/admin';

暫無
暫無

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

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