首页 > 解决方案 > 将子域重定向到 ngnix 中的相同子域 url

问题描述

我在应用程序中有多个子域。我想将其中一个子域重定向(mysubdomain.example.com)到同一子域的 url ( mysubdomain.example.com/fa/news)

我将此规则添加到 nginx 配置中。

location / {
   try_files $uri $uri/ /index.php$is_args$args;
   if ($http_host ~ "mysubdomain.example.com")
   {
      rewrite ^/$ http://mysubdomain.example.com/fa/news permanent;
   }
}

当我更改http://mysubdomain.example.com/fa/news;http://example.com/fa/news;的工作原理时,但在同一个子域中它会引发 nginx 404 错误。

我该如何解决?

标签: redirectnginxurl-rewriting

解决方案


推荐阅读