簡體   English   中英

如何在Codeigniter中從URL刪除/隱藏控制器名稱

[英]How to remove/hidden controller name from url in codeigniter

這是我的網址。 所以我該如何刪除/隱藏

home/post 

從網址

http://localhost/likes/home/post/sports/Secret-Weapons-for-Top-NFL-Teams-/13

     admin/ad_managment

   http://localhost/likes/admin/ad_managment/edit/2

謝謝

試試這個,我還沒嘗試過應該能用,

$route['(:any)/(:num)'] = "admin/ad_managment/$1/$2";
$route['(:any)/(:any)/(:num)'] = "home/post/$1/$2/$3";

查看更多http://ellislab.com/codeigniter/user-guide/general/routing.html

查看codeigniter的用戶指南,並在此示例中查看路由的完成方式。 閱讀有關代碼點火器路由的更多信息

寫入application/config/routes.php

$route['(:any)/(:any)/(:num)'] = "home/post/$1/$2/$3";

現在,您可以使用以下格式:

http://localhost/likes/sports/Secret-Weapons-for-Top-NFL-Teams-/13

Uri路由文檔: http : //ellislab.com/codeigniter/user-guide/general/routing.html

使用.htaccess重寫網址。
http://www.pets.com/pet_care_info_07_07_2008.php
RewriteEngine On#打開重寫引擎
RewriteRule ^ pet-care /?$ pet_care_info_01_02_2008.php [NC,L]
#處理“寵物照管”的請求

https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/

暫無
暫無

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

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