yii2美化URL路径

yii2美化URL路径

1、http://www.yiichina.com/download进入下载bacis的压缩包,放到项目里面;

2、在访问页面的话需要在---------在目录下bacis--->config----->web.php配置文件中加入

在components=>[中放入以下

//实现pathinfo的形式访问的配置方法-----http://www.jb51.net/article/82019.htm
//如果是apache,在入口文件(index.php)所在的目录下新建一个文本文件,接着另存为.htaccess,用记事本打开此文件加入:
'urlManager' => [
    'enablePrettyUrl' => true,//去除"?r="
    'showScriptName' => false,//该属性确定是否应将条目脚本包含在创建的URL中
    'enableStrictParsing' => false,//该enablePrettyUrl属性是强制性的,因为它会切换相当URL格式
    'rules' => [

    ],
],

]

3、去掉index.php参考以下操作:

1).如果是apache,在入口文件(index.php)所在的目录下新建一个文本文件,接着另存为.htaccess,用记事本打开此文件加入:

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

保存即可。

2)

如果是nginx,在nginx配置文件中加入:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
server {
  listen    80;
  server_name localhost;
 
  location / {
  root  E:/wwwroot/yii2.0;
  index index.html index.php;
  if (!-e $request_filename ){
   rewrite ^/(.*) /index.php last;
  }
  }
 
  location ~ \.php$ {
  root      E:/wwwroot/yii2.0;
  fastcgi_pass  127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root $fastcgi_script_name ;
  include    fastcgi_params;
  }
}

    

4)重启web服务器。

至此,配置完毕。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值