【问题标题】:How can I get the url friendly with Yii or htaccess如何获得对 Yii 或 htaccess 友好的 url
【发布时间】:2015-06-20 09:08:51
【问题描述】:

你能帮我从 htaccess 或 Yii urlManager 中获取重写规则吗

我有这个网址:

http://www.exmple.com/site/busqueda?subcategoria=Ahoyadora+de+tierras&long=&lat=

我想:

http://www.exmple.com/busqueda/Ahoyadora+de+tierras

提前致谢,

托尼

【问题讨论】:

    标签: php .htaccess yii friendly-url


    【解决方案1】:

    在 UrlManager 配置中:

    'rules' => array(
        'busqueda/<subcategoria>' => 'site/busqueda',
        // ... other rules below
    

    在控制器 SiteController.php 中:

    public action busquedaAction($subcategoria) {
    
        // do something
        var_dump($subcategoria);
    
        // render view
    }
    

    或者,你可以试试这个 .htaccess 规则

    RewriteEngine On
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule busqueda/(.+) site/busqueda?subcategoria=$1
    

    【讨论】:

      猜你喜欢
      • 2011-10-16
      • 2015-01-13
      • 1970-01-01
      • 2014-01-06
      • 1970-01-01
      • 2012-10-08
      • 2015-04-17
      • 2013-08-31
      • 2012-06-03
      相关资源
      最近更新 更多