yii url重写去掉index.php

来源:互联网 发布:sql 注入登录绕过密码 编辑:程序博客网 时间:2024/05/21 08:35
步骤一:

打开protected\config\main.php 打开该段注释…

'urlManager'=>array('urlFormat'=>'path',        //使用pathinfo模式,不需要?r='showScriptName'=>false,    //将代码里链接的index.php隐藏掉。'rules'=>array('<controller:\w+>/<id:\d+>'=>'<controller>/view','<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>','<controller:\w+>/<action:\w+>'=>'<controller>/<action>',),),

步骤二:
nginx下:
.htaccess 加入如下代码:(或是nginx.conf 那里设置?)

location / {          if (!-e $request_filename){              rewrite ^/(.*) /index.php last;          }      }
apache下:
.htaccess 加入如下代码:

Options +FollowSymLinksIndexIgnore */*RewriteEngine on# if a directory or a file exists, use it directlyRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d# otherwise forward it to index.phpRewriteRule . index.php


2 0
原创粉丝点击