nginx配置后只有根目录首页index.php能访问,其他页面404
只有首页面根目录可以访问,其他页面地址都是404 not found。网上找了半天url重定向,url重写都试了无效,要不就是重定向过多,下图为跳坑历程。
location / {
#if ($http_host !~ “^www\.nginxtest\.com/index\.php$”) {
#if ( !-f $request_filename ) {
# rewrite ^/(.+)$ http://www.nginxtest.com/index.php?$1 last;
# rewrite ^/(.+)$ http://www.nginxtest.com/index.php/$1 break;
#}
#if ($http_host ~* "^(.*)\.nginxtest\.com$") {
# set $domain $;
# rewrite ^(.*) http://www.nginxtest.com/$domain/ break;
#}
#if (-f $request_filename/index.html){
# rewrite (.*) $/index.html break;
#}
#if (-f $request_filename/index.php){
# rewrite (.*) $/index.php;
#}
#if (!-f $request_filename){
# rewrite (.*) /index.php;
#}
try_files $uri $uri/ /index.php?$query_string;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
最后使用这段代码终于正常了,希望也能帮到大家
location / {
try_files $uri $uri/ /index.php?$query_string;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
nginx配置后只有根目录首页index.php能访问,其他页面404的更多相关文章
- centos7一步一步搭建docker phpmyadmin 及nginx配置phpmyadmin非根目录重点讲解
系统环境:centos7.7 镜像image 版本:phpmyadmin/phpmyadmin(截止2020.01.10最新版) 参考文章:https://blog.csdn.net/a258929 ...
- f-stack中nginx配置后make出现error: ignoring return value of ‘ftruncate’
问题 Nginx 配置后 make 出现error: src/os/unix/ngx_process_cycle.c: In function 'ngx_start_worker_processes' ...
- nginx 配置反向代理根目录到其他服务器
location /detail/json { if ( $uri = "/detail/json" ) { rewrite "/detail/json" /i ...
- WordPress固定链接修改后访问文章页面404
如题, 修改固定链接为自定义结构后, 访问文章页面出现404的nginx错误. 解决:修改nginx.conf配置文件(/usr/local/nginx/conf/nginx.conf). 在serv ...
- Nginx配置里的fastcgi_index和index
在配置nginx时有时会遇到, 所以记录一下 location ^~ /wechat/ { index index.php; fastcgi_pass 127.0.0.1:9000; fastcgi_ ...
- nginx 配置后页面访问是报500错
该问题是html文件权限问题. 用jenkins 并远程服务器上传到另一台服务器的html ,在配置好nginx 的location root 绝对位置后还是报错500 手工用root上传时访问正常 ...
- nginx 配置后网站图片加载出来一半或者不出来
项目进行nginx反向代理后发现图片和js.css等加载很慢,甚至加载不出来. 然后查看nginx的log,发现错误如下: 2016/06/30 15:31:12 [crit] 29465#0: *1 ...
- lnmp 一键安装包 nginx配置tp5 phpinfo模式 隐藏index.php
tp5 url 线上访问 在nginx 上 出现404错误 那是因为pathinfo没有被支持 修改如下:找到 /usr/local/nginx/config/vhost/项目名.config s ...
- YII2开启路由配置后,新加的模块无法访问
最近使用YII2,自定义创建了一个自定义模块users,位置为app\modules\users. 'modules' => [ 'users' => [ 'class' => 'a ...
随机推荐
- OpenGL.Vertex Array Object (VAO) [转]
http://www.cppblog.com/init/archive/2012/02/21/166098.html 一 OpenGL抛弃glEnable(),glColor(),glVertex() ...
- 转:facebook 开源工具集合
http://codekk.com/blogs/detail/Trinea/Facebook%20%E7%9A%84%E9%82%A3%E4%BA%9B%E5%BC%80%E6%BA%90%E9%A1 ...
- getopt函数的用法
Linux提供了一个解析命令行参数的函数. #include <unistd.h> int getopt(int argc, char * const argv[], const char ...
- formidable 模块化开发 代码拆分(解耦) nodejs图片服务器架构
引言:程序要做到:健壮性.低耦合.可扩展.方便程序员分工合作 上传图片值nodejs服务器并显示图片的源代码: post.html : <!DOCTYPE html> <html l ...
- CSS Flexible 布局兼容性以及解决方案
1.兼容性 https://caniuse.com/#feat=flexbox IE11以及以下不支持. 2.解决方案 flexibility库 https://github.com/jonathan ...
- js canvas画柱状图 没什么高端的 就是一篇偶尔思路的
公司项目要用js画柱状图,本来想用个插件吧 chart.js 忽然一想 我们也用不了那么大的插件.自己写个吧,也能看看自己那点数学水平能够不! 有几个小亮点吧 1.函数x 和 函数y 对坐标进行了转化 ...
- excel单元格内插入选择项pass、fail、not support等
1.点击菜单栏的数据—-->>数据验证 2.选择 序列 在 来源 选项中填入Pass,Fail,On Going,Not Support 3.在选中的单元格并在菜单栏选中 新建规则
- Silverlight Telerik RadGridView动态增删行及行列操作(转载)
最近使用一直使用第三方控件Telerik,版本 2011 Q1,一直使用显示控件RadGridView,使用起来比DataGird好使, 也发现有控件问题. radgridview.BeginInse ...
- eclipse Alt+/ 无法提示代码
1.找到windows下的General 下的editors 下的keys 2.把word completion 的binding由原来的Alt+/该成Alt+c 3.把Content Assist下 ...
- 辛星让mysql跑的更快第一节之优化的方向和数据库建模
近期计划写一套书目,也就是关于mysql的优化的.那么首先在博客上写写,然后整理成pdf的文档的形式,当然也期待各位的关注了.对于mysql的优化是一个比較大的话题.可优化的地方也非常多,大致想了一下 ...