› NGINX
› NGINX Trac
› 3rd Party Modules
› Security Advisories
› CHANGES
› OpenResty
› ngx_lua
› Tengine
在线学习资源
› NGINX 开发从入门到精通
NGINX Modules
› ngx_echo
Alucns
V2EX  ›  NGINX

求 Apache Rewrite 转 Nginx Rewrite

  •  
  •   Alucns · May 1, 2022 · 2335 views
    This topic created in 1607 days ago, the information mentioned may be changed or developed.
    Options +FollowSymlinks
    RewriteEngine on
    RewriteRule ^([^./]+)/?$ $1.php [L]
    这条 Apache Rewrite 作用是:
    如: https://demo.com/api/validation.php 可以通过 https://demo.com/api/validation 访问;
    api/下面所有文件都可以这样访问;
    在 Nginx 下试了没有作用,求帮助,谢谢!
    location /api/ {
    try_files $uri $uri/ /api/$uri.php?$args;
    }
    Alucns
        1
    Alucns  
    OP
       May 1, 2022   ❤️ 1
    已解决:
    location / {
    try_files $uri $uri/ $uri.php$is_args$args;
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   847 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 21:11 · PVG 05:11 · LAX 14:11 · JFK 17:11
    ♥ Do have faith in what you're doing.