V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
NGINX
NGINX Trac
3rd Party Modules
Security Advisories
CHANGES
OpenResty
ngx_lua
Tengine
在线学习资源
NGINX 开发从入门到精通
NGINX Modules
ngx_echo
kenneth
V2EX  ›  NGINX

Nginx的rewrite规则和apache的改写规则有何不同?

  •  
  •   kenneth · 2012-08-24 18:30:31 +08:00 · 3001 次点击
    这是一个创建于 4289 天前的主题,其中的信息可能已经有所发展或是发生改变。
    求教一条改写规则
    apache下
    RewriteRule ^login$ login.php
    求nginx下???
    5 条回复    1970-01-01 08:00:00 +08:00
    jylee
        1
    jylee  
       2012-08-24 18:41:46 +08:00
    location /
    {
    rewrite ^/login$ /login.php last;
    }

    貌似是这样。。。
    ljbha007
        2
    ljbha007  
       2012-08-24 21:12:13 +08:00
    nginx的rewrite可以兼容apache的规则
    ljbha007
        3
    ljbha007  
       2012-08-24 21:12:33 +08:00
    记得是写到.htaccess文件里边就OK了
    feiandxs
        4
    feiandxs  
       2012-08-24 22:13:50 +08:00
    @ljbha007 不兼容……
    nginx的conf自然可以引用web下的.htaccess文件
    但不能说就兼容了
    只不过从apache的rewrite改写成nginx的不是很复杂,而且网上有现成的转换工具,这点很贴心。
    .htaccess你直接修改了内容apache就能自动载入,可以说是个解析型的。
    nginx的规则必须手动重载才行,可以说是个编译型的。
    liuyanghejerry
        5
    liuyanghejerry  
       2012-08-25 11:28:11 +08:00
    LS+1。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   4982 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 06:40 · PVG 14:40 · LAX 23:40 · JFK 02:40
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.