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 ...
随机推荐
- related_name
定义表Apple: class Apple( models.Model): origin_level = models.ForeignKey(AppleLevel) new_level = model ...
- Vue 学习(1)
<!DOCTYPE html> <html lang="en" dir="ltr"> <head> <meta cha ...
- Linux下Docker快速部署LAMP
文章目录 拿来即用 获取LAMP LAMP版本 icoty1/lamp:v1.1.0制作过程 获取ubuntu基础镜像 安装依赖 mysql apache/php phpmyadmin 使apache ...
- zuul ci
. ├── a_module ├── b_module ├── lib ├── zuul │ ├── check │ ├── ci │ ├── gate │ ├── layout.ya ...
- thinkphp3.2.3集成腾讯云短信文档流程
昨天晚上折腾了一个小时没解决 今天折腾了20分钟就搞定了 看了thinkphp3.2.3的命名空间解释方法 把文件放到这里 /ThinkPHP/Library/Org/ 把新建了一个Sms文件夹 把 ...
- B树与B+ 树
本文转载自:http://www.cnblogs.com/yangecnu/p/Introduce-B-Tree-and-B-Plus-Tree.html 维基百科对B树的定义为“在计算机科学中,B树 ...
- STS临时授权访问OSS
STS临时授权访问OSS OSS 可以通过阿里云 STS (Security Token Service) 进行临时授权访问.阿里云 STS 是为云计算用户提供临时访问令牌的Web服务.通过 STS, ...
- springboot学习随笔(二):简单的HelloWorld
接上章搭建好springboot环境后,开始开发入门级HelloWorld 一.构建简单的springboot项目 1.新建项目,选择Spring/Spring Starter Project 2.N ...
- node环境
下载教程:http://www.runoob.com/nodejs/nodejs-install-setup.html 选择版本下载:https://nodejs.org/en/download/ 输 ...
- spring Date格式问题
起因: 在数据库设计中,日期时间等类型字段一般设置为Datetime格式,所以有时在接口请求实体bean中,对应的接口字段的数据类型可能会被设置为Date类型. 而在java常用场景中的时间格式一般有 ...