简体   繁体   中英

.htaccess url rewrite code in CodeIgniter

My site url is:

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

I want to rewrite the url as:

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

What would be the url rewrite rule for this?

I tried:

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

but that did not work.

I suggest you add a "route" rule by modifying

application/config/routes.php

instead of adding rules for .htaccess file. This is CI reference topic: http://codeigniter.com/user_guide/general/routing.html

sample code:

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

if you got other categories, just like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM