Yii2.0 解决“the requested URL was not found on this server”问题
在你下了 Yii 框架,配置完路由 urlManager 后,路由访问页面会报错“the requested URL was not found on this server”,url类似于这种“https://www.cnblogs.com/site/index”。
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,//不显示.php
'suffix' => '.html',//后缀
'rules' => [
"<controller:\w+>/<action:\w+>/<id:\d+>"=>"<controller>/<action>",
"<controller:\w+>/<action:\w+>"=>"<controller>/<action>"
],
],
解决方法:
方法一:删除项目下的 runtime 文件夹,然后强刷页面。
方法二:在项目文件夹下面添加 “.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
或者这个也可以(两个选一个)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
添加以后再刷新页面,就会发现可以正常访问了,完美解决。
什么是 .htaccess?
.htaccess是一个纯文本文件,它里面存放着Apache服务器配置相关的指令。
当我们使用apache部署一个网站代码准备部署到网上的时候,我们手中的apache的httpd.conf大家肯定都知道。这是apache的配置文件,然而我们大多数的网站都是基于云服务器来部署的,还有就是团队协作开发的时候,我们很难直接修改公共的httpd.conf,这时 .htaccess就是httpd.conf的衍生品,它起着和httpd.conf相同的作用。
.htaccess 的作用?
URL重写、自定义错误页面
MIME类型配置
访问权限控制等
主要体现在伪静态的应用
图片防盗链
自定义404错误页面
阻止/允许特定IP/IP段
目录浏览与主页
禁止访问指定文件类型
文件密码保护
Yii2.0 解决“the requested URL was not found on this server”问题的更多相关文章
- php ci 报错 Object not found! The requested URL was not found on this server. If you entered the URL manually please check
Object not found! The requested URL was not found on this server. The link on the referring page see ...
- 404 Not Found The requested URL * was not found on this server
1. 把从SVNcheckout下来的代码搭建起来.CakePHP+mysql.改动数据库配置. 2. 配置虚拟主机,发现訪问不了/user/login这个URL,报这个错误:404 Not Foun ...
- Not Found The requested URL / was not found on this server.
http://www.wanysys.cc/coding/php/800.html 今天在做本地PHP项目的时候,想把之前wampserver的本地虚拟服务器环境访问方式改为本地localhost访问 ...
- Object not found! The requested URL was not found on this server.... 报错解决方案
服务器(centos6.5) lnmp 报错如下 Object not found! The requested URL was not found on this server. The link ...
- The requested URL / was not found on this server——Apache配置虚拟域名后无法访问localhost
今天为了做项目,在Apache中配置了项目域名,成功访问.但是忽然发现要访问localhost突然出现The requested URL / was not found on this server. ...
- The requested URL / was not found on this server
The requested URL / was not found on this server.原因:未打开Apache的重写功能#LoadModule rewrite_module modules ...
- wampserver 的Apache启动错误提示:The requested URL / was not found on this server.
打开localhost显示以下错误 原因:之前我配置了虚拟主机,所以服务器是从虚拟环境访问的,localhost也就访问不到 解决方法:打开httpd.conf配置文件,将Include conf/e ...
- EasyUI Tabs + Yii2.0实现iframe方式打开页面(解决共用静态文件引入加载的问题)
在项目实际开发中,有将打开的各个链接页面隔离的需求(防止静态资源起冲突),这个时候常规思路就是使用iframe来实现!但遇到一个比较棘手的问题,当用easyui Tabs打开一个iframe页面时,怎 ...
- yii2.0高级框架配置时打开init.bat秒退的解决方法 (两种方法)
第一种: 这几天刚接触到yii2.0框架,在配置advanced版本时运行init.bat初始化文件时老是闪退: 用cmd运行该文件时显示:The OpenSSL PHP extension is r ...
随机推荐
- 执行计划:SET AUTOTRACE TRACEONLY
SET AUTOTRACE OFF ---------------- 不生成AUTOTRACE 报告,这是缺省模式SET AUTOTRACE ON EXPLAIN ------ AUTOTRACE只显 ...
- python-day18 JS正则,组件BootStrap、EasyUI、JQueryUI1,插件轮播,django
@第一节课程内容 js正则 登录注册验证 @text-判断字符串是否符合规定的正则 @exec-获取匹配的数据 bootstrap(组件) –css –js 学习bootstrap规则 jQueryu ...
- 不同用户操作hadoop,Permission denied: user=root, access=WRITE, inode="/user"
关于不能执行Hadoop命令 并报权限问题执行错误1.Permission denied: user=root, access=WRITE, inode="/":hdfs:supe ...
- 海外aws-ubuntu-16.04系统使用ansible安装tidb
本以为按照官方文档会比较顺利,没想到还是遇到了几个坑,毕竟pingcap不能考虑到所有问题 环境: 1.ubuntu:16.04LTS 2.python:2.7 小坑:因为第一次使用ubuntu,没想 ...
- mac电脑复制键失灵
mac键按command+c偶尔失灵打电话给客服. 客服的解决方案: 1.关机状态同时按: shiflt+option+control+关机键 (重置键盘快捷键不会丢失数据) 20秒 2.松开后重 ...
- NGINX轻松管理10万长连接
先说说服务为什么使用HTTPs长连接技术?有如下几个原因:对响应时间要求较高:服务走的是公网,客户端与服务端的TCP建立的三次握手和断开的四次握手都需要40ms左右(真实数据包计算出来的),共需要80 ...
- 深度学习原理与框架- batch_normalize(归一化操作)
1. batch_normalize(归一化操作),公式:传统的归一化公式 (number - mean) / std, mean表示均值, std表示标准差 而此时的公式是 scale * (num ...
- ---- 关于Android蓝牙搜索到设备的图标显示和设备过滤
根据: https://www.douban.com/note/637446089/http://bbs.16rd.com/blog-23795-3446.html 以下摘自原文: (Android主 ...
- 获取用户登陆所在的ip及获取所属信息
package com.tcl.topsale.download.entity; public class GeoLocation { private String countryCode; priv ...
- Never Wait for Weights(带权并查集+路径压缩)
题目链接:http://acm.sdibt.edu.cn/vjudge/contest/view.action?cid=2209#problem/F !a b w 表示b比a大w ? a b 输出 ...