【问题标题】:Rewrite URL with id in Yii在 Yii 中用 id 重写 URL
【发布时间】:2014-01-09 21:53:45
【问题描述】:

我有一个使用 Yii 制作的项目,我使用一个带有变量 id 的页面。

在 config/main.php 上更新 urlManager 之前我的 id 变量的详细信息已停止。

我像这些行一样正确配置了 config/main.php:

'urlManager'=>array(
            'urlFormat'=>'path',
            'showScriptName' => false,
            'rules'=>array(
                '<controller:\w+>/<id:\d+>'=>'<controller>/view',
                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
                '/'
            ),
        ),

在 .htaccess 中

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php

完成这些参数后,我有以下对 SEO 友好的网址:

http://www.verinmuebles.co/permalink-id.html

其中 id 是获取相关内容的 ID,但我收到此 URL 的错误 404。我要做什么?

谢谢!

【问题讨论】:

    标签: javascript php html .htaccess yii


    【解决方案1】:
    'permalink-<id:\d+>.html'=>'page/view',
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多