博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
yii2 url 美化参数
阅读量:7112 次
发布时间:2019-06-28

本文共 1163 字,大约阅读时间需要 3 分钟。

所谓的url参数美化就是将冗长的字符串 进行正则替换 yii2 框架的url参数美化完成需要完成两个阶段 第一个阶段分apache和nginx 两种的配置 apache : 1.1 必须开启rewrite 模式   http.conf 中    LoadModule rewrite_module modules/mod_rewrite.so 去掉前面的注释 1.2在web目录新建 ".htaccess"文件 配置rewrite重写规则
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

b nginx 的配置  这个就比较简单了

只需要在配置文件的虚拟主机上的location / 中 写上 rewrite

location / { if (!-e $request_filename) {rewrite ^(.*)$ /index.php?s=$1 last;break;}}

 

 

 

2在yii框架中的 config的组件 urlManage

'urlManager' => [            'class' => 'yii\web\UrlManager',              'enablePrettyUrl' => true,  //开启url的支持            'showScriptName' => false,  //入口文件 index.php 不展示//            'suffix' => '.html',    //配置为静态文件后缀            'rules'=>[                  '
/
'=>'
/view',  //正则 '
/
/
'=>'
/
', '
/
'=>'
/
', ] ],

 

 

 

转载于:https://www.cnblogs.com/lt-com/p/6653647.html

你可能感兴趣的文章
泛函编程(14)-try to map them all
查看>>
使用meta实现页面的定时刷新或跳转
查看>>
[华为机试练习题]3.分解字符串
查看>>
OSGi 理论: 模块元数据 (Bundle's manifest file)
查看>>
Android fragment笔记整理
查看>>
velocity的一些优化记录
查看>>
Oracle---使用PL/SQL Developer连接Oracle12C(64位)版本
查看>>
④云上场景:浙江网商银行,三层金融云实践
查看>>
mongoDB VS PostgreSQL dml performance use python (pymongo & py-postgresql)
查看>>
Github上的star和fork是什么
查看>>
说说 ParcelJS
查看>>
2018.03.08、View的事件分发机制笔记
查看>>
基于ubuntu16.04快速构建Hyperledger Fabric网络
查看>>
前端异常处理最佳实践
查看>>
# 基于VirtualApk的Android手游SDK插件化架构(一)
查看>>
jvm类加载机制
查看>>
让更多人知道你——给开源库提交 pr
查看>>
使用ipmi调节r410的风扇转速
查看>>
Spring Cloud超简单十分钟入门实例
查看>>
Linux环境Apache2.4+mysql5.7+php5.6快速安装mysql
查看>>