[英]Multiple apps Codeigniter: remove “index.php/controller” from URL
我是CodeIgniter的新手,試圖理解基礎知識,也許還可以了解一些高級方法來設置基於MVC的應用程序。 過了一會兒,我想我也可以嘗試設置一個管理面板,並創建第二個文件夾作為管理應用程序。
這是我的文件夾結構:
www.domain.com
--frontend
--admin
每個文件夾中都有一個應用程序,它帶有自己的.htaccess文件。 波紋管是用於管理端的.htaccess文件。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /admin/
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
</IfModule>
當前工作的網址是www.domain.com/admin/index.php/admin/posts
,我試圖將其更改為w ww.domain.com/admin/posts
毫無意義。 因此,如何從網址中刪除/index.php/admin。
$config['base_url']
為每一面(管理員/前端)相應地設置,默認index.php也設置為null, $config['index_page'] = '';
這是因為我有2個不同的應用程序還是配置錯誤導致的問題嗎? 在同一站點上使用多個應用程序的最佳實踐是什么?
希望我沒有重復任何帖子,如果是的話,請不要討厭並嘗試幫助我。 我對你們所有人深表謝意。
嘗試這個
在config.php中
$config['base_url'] = '';
$config['index_page'] = '';
在.htacess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
編輯01
<link href="<?php echo base_url(); ?>css/style.css" rel="stylesheet" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.