全球主机交流论坛

标题: 哪位大哥帮忙把这个apache的伪静态转成nginx的 [打印本页]

作者: yohu    时间: 2011-7-13 19:34
标题: 哪位大哥帮忙把这个apache的伪静态转成nginx的
  1. RewriteEngine On

  2. RewriteRule ^(.*)list/(.+)_(.+)\.html$ $1/list\.php\?uid=$2&page=$3
  3. RewriteRule ^(.*)list/(.+)\.html$ $1/list\.php\?uid=$2
  4. RewriteRule ^(.*)content/(.+)\.html$ $1/content.php\?uid=$2
复制代码
我试了那个在线自动转换的网站,转了以后没用,哪位高人帮忙下,谢谢。


在线转换的结果
  1.         rewrite ^/(.*)list/(.+)_(.+)\.html$ /$1/list\.php\?uid=$2&page=$3;
  2.         rewrite ^/(.*)list/(.+)\.html$ /$1/list\.php\?uid=$2;
  3.         rewrite ^/(.*)content/(.+)\.html$ /$1/content.php\?uid=$2;
复制代码

[ 本帖最后由 yohu 于 2011-7-13 19:36 编辑 ]
作者: www4074    时间: 2011-7-13 20:05
==高人吧,不会这个
作者: 西门小三    时间: 2011-7-13 21:34
nginx如果直接放进伪静态专用的conf
需要定义主机头
作者: yohu    时间: 2011-7-13 21:38
原帖由 360111697 于 2011-7-13 20:18 发表
nginx不支持.htaccess的 请问你把规则放在哪里了?


我知道啊,我是要加进nginx.conf里面啊,但是我按自动转换的加进去不能用。
作者: yohu    时间: 2011-7-13 21:41
原帖由 西门小三 于 2011-7-13 21:34 发表
nginx如果直接放进伪静态专用的conf
需要定义主机头



主机头?是指绑定域名是吧?有啊,我配置原来都有,已经在用的了。我现在的配置,中间那段就是我加进去的伪静态规则,但是没用。
  1. server {
  2.         listen 12.34.56.78:80;
  3.         root /var/www/abc;
  4.         index index.php index.html index.htm;
  5.         server_name abc.com;

  6.        location = / {

  7.         rewrite ^(.*)list/(.+)_(.+)\.html$ $1/list\.php\?uid=$2&page=$3 last;
  8.         rewrite ^(.*)list/(.+)\.html$ $1/list\.php\?uid=$2 last;
  9.         rewrite ^(.*)content/(.+)\.html$ $1/content.php\?uid=$2 last;

  10.        }


  11.         location ~ \.php$ {
  12.                 fastcgi_pass 127.0.0.1:9000;
  13.                 fastcgi_index index.php;
  14.                 fastcgi_param SCRIPT_FILENAME /var/www/abc$fastcgi_script_name;
  15.                 include fastcgi_params;
  16.         }
  17.        }

复制代码

作者: 西门小三    时间: 2011-7-13 21:46
看上去应该没问题,不懂,问高人。
作者: 神马皆浮云    时间: 2011-7-13 21:47
小夜是砖家
作者: lemss    时间: 2011-7-13 22:42
转换的可以啊
作者: yohu    时间: 2011-7-14 00:24
原帖由 lemss 于 2011-7-13 22:42 发表
转换的可以啊



就是测试了不行,我测试了N遍,都是不生效,打开静态页面,全部404。
作者: dianso    时间: 2011-7-14 00:35
把规则单独做个文件放到nginx/conf里面

然后域名的conf文件include 123.conf就可以了
作者: yohu    时间: 2011-7-15 10:18
标题: 回复 11# dianso 的帖子
还是不行哦,结果是一样的。。。
作者: 西门小三    时间: 2011-7-15 13:00
原帖由 yohu 于 2011-7-15 10:18 发表
还是不行哦,结果是一样的。。。

rewrite ^/list/(.+)_(.+)\.html$ /list\.php\?uid=$1&page=$2
rewrite ^/list/(.+)\.html$ /list\.php\?uid=$1
rewrite ^/content/(.+)\.html$ /content.php\?uid=$1

我自己改了个,这是主体部分,其他神马的你自己完善。
作者: yohu    时间: 2011-7-16 11:06
标题: 回复 13# 西门小三 的帖子
谢谢楼上帮忙,不过,测试了,还是404……




欢迎光临 全球主机交流论坛 (https://hostloc.9hanju.com/) Powered by Discuz! X3.4