VPS侦探论坛

 找回密码
 注册
查看: 4843|回复: 5

军哥帮一下忙,看一下这个301重定向有什么问题?

[复制链接]
发表于 2013-8-28 02:40:05 | 显示全部楼层 |阅读模式

if (!-e $request_filename){

rewrite .*/(.+).php$ /$1.php permanent;
  }
这段规则是Discuz!目录化伪静态时,IE下不能从根目录跳转的问题时用的。
这个规则放在 location ~ .*\.(php|php5)?$ { }里面,如果是php动态文件,会跳转到根目录,这在nginx默认的配置下,是可以起作用的。
但用在LNMP上就不起作用了,能不能帮看一下是什么原因?
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2013-8-28 08:18:54 | 显示全部楼层


不用加在php解析的location里面
直接在php解析的location前面加上就行
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
 楼主| 发表于 2013-8-28 22:37:46 | 显示全部楼层

军哥,我加上去以后,在IE浏览器下还是不能跳转。请帮忙看一下我加得对不对。
  1. listen       80;
  2.                 server_name www.xunwuwang.com;
  3.                 index index.html index.htm index.php default.html default.htm default.php;
  4.                 root  /home/wwwroot/xunwuwang.com;

  5.                 include xunwuwang.conf;
  6.                 error_page 404 /404.html;

  7.                 if (!-e $request_filename){
  8.                 rewrite .*/(.+).php$ /$1.php permanent;
  9.                 }

  10.                 location ~ .*\.(php|php5)?$
  11.                         {
  12.                                 try_files $uri =404;
  13.                                 fastcgi_pass  unix:/tmp/php-cgi.sock;
  14.                                 fastcgi_index index.php;
  15.                                 include fcgi.conf;
  16.                         }
复制代码
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
 楼主| 发表于 2013-8-29 09:12:27 | 显示全部楼层



把这段代码放在前后都不行,请达人指点迷津。
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2013-8-29 10:04:03 | 显示全部楼层

配置没错,我这边测试也正常跳转
可能和你伪静态冲突

/usr/local/nginx/sbin/nginx -t 测试看看

军哥运维代购:http://shop63846532.taobao.com/

 楼主| 发表于 2013-8-29 14:32:12 | 显示全部楼层

回复 5# 的帖子


/usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
测试结果正常的
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-9-24 23:23 , Processed in 0.028137 second(s), 17 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表