【问题标题】:.htaccess url rewrite code in CodeIgniter.htaccess url 在 CodeIgniter 中重写代码
【发布时间】:2012-02-03 00:19:57
【问题描述】:

我的网址是:

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 

但这没有用。

【问题讨论】:

    标签: php mysql .htaccess codeigniter


    【解决方案1】:

    我建议你通过修改添加“路由”规则

    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';
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多