• 请不要在回答技术问题时复制粘贴 AI 生成的内容
liKeYunKeji
V2EX  ›  程序员

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

  •  
  •   liKeYunKeji · Sep 28, 2020 · 1128 views
    This topic created in 2155 days ago, the information mentioned may be changed or developed.

    我有个公共页面

    例如
    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  
       Sep 28, 2020
    nginx 的伪静态规则和 apache 的相差不大。 我印象中 区别是 对于路径。
    例如,根目录伪静态,apache 没 / 。nginx 需要在原有规则加上 / 。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3442 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 04:44 · PVG 12:44 · LAX 21:44 · JFK 00:44
    ♥ Do have faith in what you're doing.