码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2015-10-14 23:22:58      阅读:185      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!