V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
ninestep
V2EX  ›  问与答

thinkPHP 使用 caddy 如何写重写规则?

  •  1
     
  •   ninestep · 2019-03-15 18:44:37 +08:00 · 2409 次点击
    这是一个创建于 1840 天前的主题,其中的信息可能已经有所发展或是发生改变。

    第一次使用 caddy,在网上复制了

        rewrite {
            to {path} {path}/ /index.php?s={uri}
        }
    

    这样的一个重写规则,正常的可以满足,但是一旦遇到

    /admin/Articles/index.html?pageNumber=1&pageSize=10&type=58&searchText=
    

    这样的地址就会报 404 错误 求那位大神给个能用的重写规则

    2 条回复    2019-03-15 21:49:40 +08:00
    ninestep
        1
    ninestep  
    OP
       2019-03-15 19:01:24 +08:00
    自己找出了原因了,因为重写规则里面有了?号,而匹配到的{uri}也有一个?号,所以最终有了两个?号导致系统错乱,只需要改成
    ~~~
    rewrite {
    to {path} {path}/ /index.php/{uri}
    }
    ~~~
    就可以完美解决问题
    choicky
        2
    choicky  
       2019-03-15 21:49:40 +08:00 via iPhone
    《 Thinkphp 在 Apache、Nginx 和 Caddy 的伪静态重写规则》

    https://itlaws.cn/post/thinkphp-rewrite-apache-nginx-caddy/
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1009 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 22:02 · PVG 06:02 · LAX 15:02 · JFK 18:02
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.