容器技术交流

 找回密码
 立即注册
查看: 4307|回复: 5

nginx 关于rewirte 高手帮帮忙!洞洞

[复制链接]
发表于 2009-9-21 12:25:18 | 显示全部楼层 |阅读模式
我其实就想做一个跳转

老的服务器可以运行 asp,所以很多以前的页面中都带有 ab.asp?z=123 这样的连接,
现在换服务器了,我想把 凡是 访问ab.asp?z=123这样的连接 都引到 ab.php?z=123来运行,
我用FAMP配置的服务器在内网运行,

在配置文件中写了如下一条
rewrite "/abm.asp" /abm.php last;

想测试一下
结果重启 nginx的时候报错误
[emerg] 2839#0: unknown directive "rewrite" in /usr/local/nginx/conf/nginx.conf:44

本人菜鸟,要想开启rewirte功能是否还要开启什么模块 什么的么?
请帮解答下。。。。

全部配置文件如下:
user  daemon;
worker_processes  4;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        logs/nginx.pid;

events {
    worker_connections  4096;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] $request '
    #                  '"$status" $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  /dev/null  combined;
    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  120;

    fastcgi_send_timeout 300;
    fastcgi_connect_timeout 300;
    fastcgi_read_timeout 300;

    server_names_hash_bucket_size 128;

    client_max_body_size 600M;

    gzip  on;

    include vhost.conf;

}
rewrite "/abm.asp" /abm.php last;
 楼主| 发表于 2009-9-21 12:27:49 | 显示全部楼层
前提 不更改 vhost.conf里的文件 我怕对后台有影响呢
 楼主| 发表于 2009-9-21 12:38:22 | 显示全部楼层
或者谁能告诉我下 在 FAMP的后台里怎么写呀?
将  ab.asp?z=123 这样的定义成 ab.php?z=123
发表于 2009-9-21 13:42:06 | 显示全部楼层
我觉得你应该这么写吧

rewrite ^/ab.asp?z=([0-9]+)$ /ab.php?z=$1 last;
 楼主| 发表于 2009-9-21 13:46:42 | 显示全部楼层
我试试 谢谢昂~昂
 楼主| 发表于 2009-9-21 13:56:45 | 显示全部楼层
不知道怎么老是跳到首页去 我装的SS~
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Archiver|URLOS ( 粤ICP备18087780号 )

GMT+8, 2025-5-11 07:19 , Processed in 0.028181 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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