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 ...
随机推荐
- intellij idea工具 DeBug调试
断点的设定和eclipse一样,只要点一下就可以,下面是我设定的几个断点,再下面的三个窗口是用来调试代码的,这个和eclipse类似 调试常用的快捷键 F9 resume programe 恢复程序 ...
- 接口测试 - ti
脚本 主程序 #!/bin/bash . /etc/ti/ti.conf . /etc/ti/ti.fun #-basic.json | curl -H "Content-Type:appl ...
- mosquitto broker 安装服务后启动失败
一.失败原因 由于做项目用到Mqtt协议,需要安装mosquitto broker 服务,在自己本地笔记本电脑安装后直接启动服务是可以的.后来部署到服务器启动,报错缺少msvcr100.dll ,由于 ...
- pytorch安装 caffe2 安装:git 慢 caffe2 cannot find -lopencv_dep_cudart ,undefined reference to 'pthread_create'
最开始的问题: caffe2目前已经不维护了.怎么编译都报错,并且有third_party的代码链接已经飞了.下载不全代码了.建议 不要再折腾了,直接安装Pytorch. 首先,基本环境是ubuntu ...
- CentOS 7设置yum仅仅下载rpm不安装总结
前言 参考文章:https://linux.cn/article-7937-1.html 在参考文章的基础上进行总结. 使用download-only插件实现 首先我们可以使用downloadonly ...
- wdcp lanmp 安装+搭建网站+安全狗安装 详细实用
先说一下WDCP,其实就是一个集成环境,优点是有后台可视化面板操作,不像一般的linux似的 都要用代码命令! Linux 的PHP 环境一般就是两个搭配 [mysql+Apache+PHP]和[My ...
- tensorflow,object,detection,在model zoom,新下载的模型,WARNING:root:Variable [resnet_v1_50/block1/unit_3/bottleneck_v1/conv3/BatchNorm/gamma] is not available in checkpoint
现象: WARNING:root:Variable [resnet_v1_50/block1/unit_1/bottleneck_v1/conv1/BatchNorm/beta] is not ava ...
- Linux 用户与组
在 Linux 操作系统下,如何添加一个新用户到一个特定的组中?如何同时将用户添加到多个组中?又如何将一个已存在的用户移动到某个组或者给他增加一个组?对于不常用 Linux 的人来讲,记忆 Linux ...
- Game Engine Architecture 5
[Game Engine Architecture 5] 1.Memory Ordering Semantics These mysterious and vexing problems can on ...
- BOOST_PREVENT_MACRO_SUBSTITUTION
[BOOST_PREVENT_MACRO_SUBSTITUTION] 用于防止函数被macro替换的问题. 例如: 参考: 1.https://blog.csdn.net/yanxiangtianji ...