yii的pathinfo方式实现
yii2.0在浏览器中默认查看控制器下的方法是 http://ltbk.cn/index.php?r=login/login
要是在浏览器上输出 http://ltbk.cn/index.php/login/login就更加方便
下面解决方法:
1. 打开config目录下的web.php,在$config = [ ‘components’=>[] ]中加入以下内容:
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
'http://m.'.$params['domain'].'/<c:[a-z0-9]+>/<a:[a-z0-9]+>' => 'mobile/<c>/<a>',
'http://m.'.$params['domain'].'/' => 'mobile/default/index',
],
],
不过路径还是形如:ltbk.cn/index.php/post/index
2.配置Apache
在yii2.0 默认的入口文件 web/index.php 的同一级下创建一个文本文件 命名为.htaccess
并添加内容
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
3.重启Apache
yii的pathinfo方式实现的更多相关文章
- yii控制布局方式
1:在控制器内成员变量设置 public $layout = false; //不使用布局 public $layout = “main”; //设置使用的布局文件 2:在控制器成员方法内设置 $th ...
- Yii源码阅读笔记(三十二)
web/Application类的注释,继承base/Application类,针对web应用的一些处理: namespace yii\web; use Yii; use yii\base\Inval ...
- 三级联动(在YII框架中)
//三级联动 //数据库代码过多就不上传了 //视图 <div class="area"> <table class="table"&g ...
- Yii源码阅读笔记(二十一)——请求处理流程
Yii2请求处理流程: 首先:项目路径/web/index.php (new yii\web\Application($config))->run();//根据配置文件创建App实例,先实例化y ...
- Yii常用路径说明
原作者地址:http://www.kuitao8.com/20140520/2483.shtml //framework路径 Yii::getFrameworkPath(); //protected/ ...
- Yii路径总结
如果是 // 就会默认去调 protected/views/layouts //代表 绝对路径 其实 就是 绝对和相对的关系 /代表相对路径,如module/user下的layout 用单斜杠的话默认 ...
- yii框架常用url地址
调用YII框架中 jquery:Yii::app()->clientScript->registerCoreScript('jquery'); framework/web/j ...
- yii 常用路径
yii::app()->homeurl //主页的网址 yii系统变量. //得到proteced目录的物理路径 Yii::app()->basePath; 调用YII框架中jquery: ...
- yii 获取当前ip 常用的调用变量
echo Yii::app()->request->hostInfo; //除域名外的URL echo Yii::app()->request->getUrl(); //除域名 ...
随机推荐
- poj1837 01背包(雾
Description A train has a locomotive that pulls the train with its many passenger coaches. If the lo ...
- B. Petya and Divisors 解析(思維)
Codeforce 111 B. Petya and Divisors 解析(思維) 今天我們來看看CF111B 題目連結 題目 略,請看原題 前言 看了別人的解答就豁然開朗 @copyright p ...
- python装饰器是什么?
装饰器是python中的高阶语法,装饰器是通过类或者函数来实现的,通常使用@符号来表示一个装饰器,作用是用来扩展某个函数或者类的功能
- spring mvc 中获取HttpServletRequest ,HttpServletResponse
spring中的bean最常用的 singleton 模式 如果要在springmvc Controller 中获取 HttpServletRequest ,HttpServletResponse ...
- Luogu P2179 [NOI2012]骑行川藏
题意 给定 \(n\) 个路段,每个路段用三个实数 \(s_i,k_i,v^\prime_i\) 描述,最小化 \[F(v_1,\cdots v_n)=\sum\limits_{i=1}^{n}\fr ...
- 【Javac编译异常】javac编译提示jdk中的包找不到的问题error: package jdk.internal.org.objectweb.asm does not exist 和 error: cannot find symbol
一.复现步骤 1)编写待编译的java类 package f_asm_and_javassist; import jdk.internal.org.objectweb.asm.*; import ja ...
- python机器学习实现逻辑斯蒂回归
逻辑斯蒂回归 关注公众号"轻松学编程"了解更多. [关键词]Logistics函数,最大似然估计,梯度下降法 1.Logistics回归的原理 利用Logistics回归进行分类的 ...
- 【jmeter】实现接口关联的两种方式:正则表达式提取器和json提取器
关联通俗来讲就是把上一次请求的返回内容中的部分截取出来保存为参数,用来传递给下一个请求使用. 示例: 1.用户密码进行登录,登录后生成authentication 2.需要将登录接口响应结果中auth ...
- MIPS学习笔记(一)
写在前面 本文是根据"MIPS Assembly Language Programming CS50 Discussion and Project Book. Daniel J. Ellar ...
- springboot + post 中文乱码
去检查你的 filter 配置,是否配置了一个最高优先级的 filter, 这个最高优先级的 filter 会影响 springboot 自动配置的 CharacterEncodingFilter.原 ...