要实现一个文章页面跳转到其他二级域名的Nginx伪静态规则,可以使用Nginx的rewrite指令。

假设你的文章页面的URL为:https://example.com/article/page.html,要跳转到其他二级域名:https://subdomain.example.com/page.html。

在Nginx的配置文件中,你可以添加以下规则:

server {
    listen 80;
    server_name example.com;

    location /article/ {
        rewrite ^/article/(.*)$ https://subdomain.example.com/$1 permanent;
    }
}

这个配置中,设置了监听80端口,并指定了服务器名为example.com。在location /article/块中,使用rewrite指令将/article/后面的路径捕获到$1变量中,并构造新的URL https://subdomain.example.com/$1。

注意,这里使用了permanent关键字,表示进行永久重定向。如果想要临时重定向,可以使用redirect关键字。

另外,记得重启或重新加载Nginx配置以使修改生效

某个文章页面跳转到其他二级域名的Nginx伪静态规则怎么写

原文地址: http://www.cveoy.top/t/topic/iJyE 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录