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 ...
随机推荐
- spring注入之使用标签 @Autowired @Qualifier
使用标签的缺点在于必需要有源代码(由于标签必须放在源代码上),当我们并没有程序源代码的时候.我们仅仅有使用xml进行配置. 比如我们在xml中配置某个类的属性 <bea ...
- Apache 使用gzip、deflate 压缩页面加快网站访问速度
Apache 使用gzip 压缩页面加快网站访问速度 介绍: 网页压缩来进一步提升网页的浏览速度,它完全不需要任何的成本,只不过是会让您的服务器CPU占用率稍微提升一两个百分点而已或者更少. 原理 ...
- POJ 3071 Football 【概率DP】
Football Football Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3734 Accepted: 1908 ...
- HttpClient POST 的 UTF-8 编码问题
http://www.360doc.com/content/09/0915/15/61497_6003890.shtml不 过在实际使用中, 还是发现按照最基本的方式调用 HttpClient 时, ...
- 通过xsd schema结构来验证xml是否合法
import sys import StringIO import lxml from lxml import etree from StringIO import StringIO # Constr ...
- tcp/ip ---IP路由选择
从概念上说, I P路由选择是简单的,特别对于主机来说.如果目的主机与源主机直接相连(如点对点链路)或都在一个共享网络上(以太网或令牌环网),那么I P数据报就直接送到目的主机上.否则,主机把数据报发 ...
- SDUTOJ 2775 小P的故事——奇妙的饭卡
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvUl9NaXNheWE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA ...
- CF Codeforces Round #256 (Div. 2) D (448D) Multiplication Table
二分!!! AC代码例如以下: #include<iostream> #include<cstring> #include<cstdio> #define ll l ...
- 使用 %matplotlib inline 出错?
%matplotlib inline 是一个魔法函数(Magic Functions).官方给出的定义是:IPython有一组预先定义好的所谓的魔法函数(Magic Functions),你可以通过命 ...
- c#中从string数组转换到int数组及比较两个字符串相等
string[] input = { "1", "2", "3", "4", "5", " ...