簡體   English   中英

.htaccess url在CodeIgniter中的重寫代碼

[英].htaccess url rewrite code in CodeIgniter

我的網站網址是:

http://www.thebestincanada.ca/index.php?site/searchOther/restaurant/Victoria

我想將網址改寫為:

http://www.thebestincanada.ca/restaurant/Victoria

URL重寫規則是什么?

我試過了:

RewriteEngine on
RewriteRule ^([0-9A-Za-z\-]+)/([0-9]+)-([0-9]+) default.php?title=$1&cat=$2&subcat=$3 

但這沒有用。

我建議您通過修改添加“路由”規則

application / config / routes.php

而不是為.htaccess文件添加規則。 這是CI參考主題: http : //codeigniter.com/user_guide/general/routing.html

樣例代碼:

route['restaurant/(.*)']='site/searchOther/restaurant/$1';

如果您還有其他類別,則如下所示:

route['((restaurant|shop|park)/.*)']='site/searchOther/$2';

暫無
暫無

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

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