ninestep
V2EX  ›  问与答

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

  •  1
     
  •   ninestep · Mar 15, 2019 · 3311 views
    This topic created in 2642 days ago, the information mentioned may be changed or developed.

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

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

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

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

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

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

    https://itlaws.cn/post/thinkphp-rewrite-apache-nginx-caddy/
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1046 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 19:03 · PVG 03:03 · LAX 12:03 · JFK 15:03
    ♥ Do have faith in what you're doing.