[英]Rewrite all PHP urls to a specific url in nginx
如何将所有PHP请求重写为一个特定的URL?
例如这些网址
https://somesite.com/thing.php
https://somesite.com/dir/ (包含index.php)
将重定向到此: https : //somesite.com/dir/someotherthing.php
我还想保持客户端URL不变:
例如, https://somesite.com/thing.php应该仍然是相同的URL,而不是立即更改为https://somesite.com/dir/someotherthing.php
另一个问题,当我这样做时,PHP中的$_SERVER['REQUEST_URI']
仍然是客户端的请求URL吗? 如果没有,我如何将其传递给https://somesite.com/dir/someotherthing.php ?
您不能通过服务器端触摸客户端URL来重定向客户端。
为此使用AJAX。 您寻找的行为在某些方面类似于SPA应用程序与API交互的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.