首页 > Web开发 > 详细

Yii 1.0 伪静态即Yii配置Url重写(转)

时间:2015-10-14 23:21:01      阅读:294      评论:0      收藏:0      [点我收藏+]

第一步:配置 URL Management(网址管理)

只需要在config文件夹下面的main.php文件中进行配置就好了

‘components‘ => array(
    ‘urlManager‘ => [
      ‘showScriptName‘ => false,//这里是隐藏index.php那个路径的
      ‘urlFormat‘ => ‘path‘,
      ‘rules‘ => [
        ‘<controller:\w+>/<id:\d+>‘ => ‘<controller>/view‘,
        ‘<controller:\w+>/<action:\w+>/<id:\d+>‘ => ‘<controller>/<action>‘,
        ‘<controller:\w+>/<action:\w+>‘ => ‘<controller>/<action>‘
      ]
    ],
    ‘user‘ => array(
      
      // enable cookie-based authentication
      ‘allowAutoLogin‘ => true
    ),<span style="font-family: Arial, Helvetica, sans-serif;">)</span>

第二步:进行apache配置

yii中有个文件:.htaccess 用来专门配置apache服务器的,这个文件下面配置输入下面的代码

<IfModule mod_rewrite.c>
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on

# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# otherwise forward it to index.php
RewriteRule . index.php
</IfModule>

这个文件配置好了之后,一定要把apache中的rewrite模块开启:

技术分享

然后就OK了。

整个URL的配置就已经完成了。

Yii 1.0 伪静态即Yii配置Url重写(转)

原文:http://www.cnblogs.com/lccjob/p/4879028.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!