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 ...
随机推荐
- resttemlate
package com.xjj; import java.util.List; import java.util.Map; import java.util.stream.Collectors; im ...
- 【HDFS API编程】图解客户端从HDFS读数据的流程
- Spring boot 自定义拦截器
1.新建一个类实现HandlerInterceptor接口,重写接口的方法 package com.zpark.interceptor; import com.zpark.tools.Constant ...
- LeetCode 101. Symmetric Tree 判断对称树 C++
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For e ...
- 关于JWTtoken的管理问题
JWT简介: Json web token (JWT), 是为了在网络应用环境间传递声明而执行的一种基于JSON的开放标准.因为网络上有很多关于jwt的详细介绍了,所以我这里就不再赘述.但是JWT的大 ...
- leetcode974
这道题目描述很清晰,直接两层循环,代码如下: class Solution(object): def subarraysDivByK(self, A: 'List[int]', K: int) -&g ...
- RocketMQ入门(消费者)_3
消费者角色: 1. 推式(一般建议用推式) 2. 拉式 消费模式: 1. 集群(cluster) --均衡负载消费 2. 广播(broadcasting) --发布和订阅 ...
- activiti官网实例项目activiti-explorer实操详情
参考链接:https://www.xuchuruo.cn/Activiti-modeler%E6%95%B4%E5%90%88%E5%88%B0Spring.html 按照链接文章提示操作完成之后,启 ...
- json与csv的基础用与法
json库是处理json格式的python标准库 有两个过程: 编码(encoding):将python数据类型转换为json格式的过程 解码(decoding):从json格式中解析数据得到的pyt ...
- MySQL后台线程整理总结
本文整理自<MySQL技术内幕 InnoDB存储引擎> MySQL通过后台各种线程.内存池.文件交互来实现对外服务的,不同线程实现不同的资源操作,各个线程相互协助,共同来完成数据库的服务. ...