yii框架 隐藏index.php 以及美化URL(pathinfo模式访问)
首先我们分步骤来:
安装好 yii 以后 我们看到的url地址如下所示:
http://www.3w.com/MyApp/backend/web/index.php?r=site%2Flogin
我们首先去掉 index.php
1.去apache配置中开启rewirte模块
2.配置好我们的虚拟主机 必须开启外部重写规则:
3.在下面的目录下 创建 .htaccess 文件
4. .htaccess文件里内容如下:
- <code class="language-php"><span style="font-size:18px;"><strong>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 </strong></span></code>
- 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.然后就成功了,试试吧
yii框架 隐藏index.php 以及美化URL(pathinfo模式访问)的更多相关文章
- Yii Framework隐藏index.php文件的步骤
Yii Framework隐藏index.php文件的步骤 作者:feebas 发布于:2012-4-23 13:36 Monday 分类:Yii Framework 1.开启apache的mod_r ...
- CI 框架隐藏index.php-ubuntu
和朋友在做一个小网站,用到了CI框架,之前测试都是在windows上,隐藏index.php也相对比较简单.但服务器是ubuntu系统,需要配置一下,根据网上看到的一些教程,结合自己电脑的特点,记录步 ...
- CI 框架 隐藏index.php 入口文件 和 设置访问application下子目录
1.隐藏根目录下 index.php, 在根目录下创建 .htaccess文件 内容如下: <IfModule mod_rewrite.c> RewriteEngine on Rewrit ...
- CodeIgniter框架隐藏index.php
问题描述:使用CodeIgniter框架做项目时,在启用REWRITE的伪静态功能的时候,首页可以访问,但是访问其它页面的时候,就提示:“No input file specified.” 原因在于使 ...
- ThinkPHP CI codeignitor 框架 apache 重写 url 隐藏index.php 服务器 报错:Object not found! 可能是.htaccess隐藏index.php
隐藏index.php可以去掉URL地址里面的入口文件index.php,但是需要额外配置WEB服务器的重写规则.以Apache为例,需要在入口文件的同级添加.htaccess文件(官方默认自带了该文 ...
- Yii框架后续
关于Yii框架遗留的知识点. 1.url路由方式 (1).问号传参(默认) eg: http://localhost/项目/app/index.php http://localhost/项目/app/ ...
- ThinkPHP5 隐藏index.php问题
隐藏index.php 可以去掉URL地址里面的入口文件index.php,但是需要额外配置WEB服务器的重写规则. 以Apache为例,需要在入口文件的同级添加.htaccess文件(官方默认自带了 ...
- YII框架安装步骤(yii框架版本1.1.20,时间是2018/11)
0x01 首先中文官网下载https://www.yiichina.com/download 0x02 解压压缩包到www目录下(方便以后调试) 0x02-1 如果想看一下你的电脑是否能匹配yii框架 ...
- yii框架美化访问路径,去掉index.php/?r=部分
一.找到配置文件(ps:advance高级模板) 在工程目录-> backend目录 或 frontend目录 -> config目录 -> main.php文件 -> 在 r ...
随机推荐
- android升级gradle到3.4.1
这两天把gradle升级到了gradle-3.4.1 com.android.tools.build:gradle升级到了com.android.tools.build:gradle:2.3.0 结果 ...
- percona-toolki安装冲突(my.cnf Percona-Server-shared与mysql-community-server)
最近在安装percona-toolkit工具包时,提示在my.cnf文件中, Percona-Server-shared与mysql-community-server冲突.起初还以为是一定需安装Per ...
- (转)查看SQLServer最耗资源时间的SQL语句
原文地址:https://www.cnblogs.com/My-Dream/p/6270308.html 1.找出执行时间最长的10条SQL(适用于SQL SERVER 2005及其以上版本) SEL ...
- μC/Probe尝鲜
μC/Probe 1.添加文件 2.配置probe_com_cfg.h 2.1.选择接口 #define PROBE_COM_CFG_RS232_EN DEF_ENABLED /* Configure ...
- 二、CSS选择器
1.CSS派生选择器 概念:通过依据元素在其位置的上下文关系来定义样式. 实例: <!--index.html--> <!DOCTYPE html> <html lang ...
- BZOJ 4872 luogu P3750 [六省联考2017]分手是祝愿
4872: [Shoi2017]分手是祝愿 Time Limit: 20 Sec Memory Limit: 512 MB[Submit][Status][Discuss] Description ...
- gentoo Cataclysm - Dark Days Ahead
gentoo 中安装 Cataclysm - Dark Days Ahead,使用web 下载稳定版的安装包,使用 tar 进行解压. 安装需要共享库:sdl2-mixer, 未完待续
- flex兼容性之Webpack3+postcss+sass+css
1:⚠️⚠️ 首先安装依赖 npm install --save-dev webpack style-loader css-loader postcss-loader sass-loader auto ...
- python批量处理文件夹中文件的问题
用os模块读取文件夹中文件 原来的代码: import osfrom scipy.misc import imread filenames=os.listdir(r'./unprocess')for ...
- MANIPULATION
MANIPULATION Generalizations Congratulations! You learned how to use the command line to view and ma ...