[英]CodeIgniter Views
好的,我采用了 CodeIgniter 設置,
我在配置中的 route.php 如下所示:
$route['default_controller'] = "development";
我的 development.php 控制器如下所示:
class Development extends Controller
{
function Development() {
parent::Controller();
}
public function Index() {
$this->load->view('index');
}
function show() {
$this->load->view('show');
}
}
當我轉到根文件夾時,在我的瀏覽器中,它確實加載了 index.php 視圖,我想創建一個指向 show.php 的鏈接,該鏈接也在我的視圖目錄中。 我使用的 URL 是例如:my.server/test/codeigniter/ 但是當我去 my.server/test/codeigniter/show 我的 show.php 沒有加載。 我這樣做正確嗎?
我應該提到我也嘗試過 public function show() 但它不起作用,而且我在目錄中也沒有 .htaccess 文件
任何建議都會有所幫助!
.htaccess
文件中有兩條規則就足夠了:
# check if the requested resource is not an existing file
RewriteCond %{REQUEST_FILENAME} !-f
# rewrite internally to index.php
RewriteRule ^(.*)$ index.php [QSA,L]
Mod_rewrite
和AllowOverride All
假定已啟用。
Ken Struys 對您問題的評論是正確的。 你給控制器的默認控制器狀態意味着如果你去my.server/test
,控制器和索引函數將加載。
除此之外,您需要包含index.php/controller_name/function_name
以訪問您的控制器功能。
除非是這樣,否則你實現了一些花哨的 .htaccess url 重寫,我無法幫你。
您可以在 routes.php 中進行如下設置:
$route['show']='開發/展示';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.