V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
pytth
V2EX  ›  程序员

apache 伪静态如何转乘 nginx 伪静态 重写 URL

  •  
  •   pytth · 2020-09-28 18:06:14 +08:00 · 747 次点击
    这是一个创建于 1306 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我有个公共页面

    例如
    xxx.com/index.php?id=123

    apache 伪静态重写 URL 后是这样的
    xxx.com/123

    那么 apache 服务器伪静态.htaccess 规则是这么写的

    RewriteEngine On
    #RewriteBase / 
    RewriteRule ^(\d+)$ index.php?id=$1
    

    现在要满足 nginx 服务器要求,所以需要写 nginx 伪静态规则,不懂 nginx 的伪静态,在此请教大家。

    最好是能够集成在一个伪静态规则文件里面

    Felldeadbird
        1
    Felldeadbird  
       2020-09-28 22:15:22 +08:00
    nginx 的伪静态规则和 apache 的相差不大。 我印象中 区别是 对于路径。
    例如,根目录伪静态,apache 没 / 。nginx 需要在原有规则加上 / 。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1095 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 23:11 · PVG 07:11 · LAX 16:11 · JFK 19:11
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.