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

求 Apache Rewrite 转 Nginx Rewrite

  •  
  •   Aluhao · 2022-05-01 18:27:32 +08:00 · 1342 次点击
    这是一个创建于 719 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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;
    }
    Aluhao
        1
    Aluhao  
    OP
       2022-05-01 18:39:35 +08:00   ❤️ 1
    已解决:
    location / {
    try_files $uri $uri/ $uri.php$is_args$args;
    }
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2547 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 01:17 · PVG 09:17 · LAX 18:17 · JFK 21:17
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.