yii框架 隐藏index.php 以及美化URL
来源:互联网 发布:淘宝店主软件 编辑:程序博客网 时间:2024/05/18 03:37
首先我们分步骤来:
安装好 yii 以后 我们看到的url地址如下所示:
http://www.3w.com/MyApp/backend/web/index.php?r=site%2Flogin
我们首先去掉 index.php
1.去apache配置中开启rewirte模块
2.配置好我们的虚拟主机 必须开启外部重写规则:
3.在下面的目录下 创建 .htaccess 文件
4. .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
5.现在再次在浏览器 访问我们的项目 我们就可以去掉index.php url 如下:
http://www.3w.com/MyApp/backend/web/?r=site%2Flogin
然后我们 美化 url 如下:
http://www.yii2.com/site/index.html
我们只需要在config目录下配置即可:
2.添加如下代码:
'urlManager' => [ 'enablePrettyUrl' => true,//开启url美化 'showScriptName' => false,//隐藏index.php 'suffix' => '.html',//后缀 ],
3.然后就成功了,试试吧
阅读全文
1 0
- yii框架 隐藏index.php 以及美化URL
- YII隐藏index入口文件 美化url
- Yii URL隐藏index.php
- YII2 URL美化以及隐藏入口文件index.php
- YII如何隐藏URL中的index.php
- yii框架美化url
- PHP-Yii-URL美化
- yii 隐藏index.php
- Yii隐藏index.php
- YII隐藏index.php
- Yii隐藏URL中index.php的方法
- Yii 框架路径美化Url
- yii框架路径美化Url
- PHP: Yii 隐藏index.php
- CI框架 .htaccess 隐藏url中index.php的解决
- CI框架 .htaccess 隐藏url在index.php解决方案
- PHP5.4+内置webserver,Yii中如何隐藏index.php,让URL rewrite
- yii实践 将index.php隐藏起来
- (Spring)springdata、spring、jpa、hibernate、springsecurity、maven整合
- 多线程C++(1)
- python 字典推导公式
- python函数
- js 迭代判断字段非空
- yii框架 隐藏index.php 以及美化URL
- 使用Vue-Router 2实现路由功能
- 修改IAR工程名的办法
- Spring源码分析
- 《Scala入坑笔记》缘起 3天就搞了一个 hello world
- Jsp 基本入门
- BeautifulSoup学习笔记3
- Sql Server、Oracle数据库判断字段是否为空的办法
- MYSQL初学者使用指南