Redirect Traefik Kubernetes 301重定向

Redirect Traefik Kubernetes 301重定向,redirect,kubernetes,traefik,http-redirect,Redirect,Kubernetes,Traefik,Http Redirect,我已经通过舵图安装了traefik 我有一个域名:example.com 它有一些博客帖子 我现在创建了一个子域:subdomain.example.com 我有我的博客URL列表: /blog-1 /blog-2 基本域和子域都位于同一群集上 我希望有301重定向,以便如果有人试图访问: example.com/blog-1 它们将被重定向到: subdomain.example.com/blog-1 我不想直接使用通配符,只使用我的博客URL列表 谢谢 这是我的重定向到https的中间

我已经通过舵图安装了traefik

我有一个域名:example.com

它有一些博客帖子

我现在创建了一个子域:subdomain.example.com

我有我的博客URL列表:

/blog-1
/blog-2
基本域和子域都位于同一群集上

我希望有301重定向,以便如果有人试图访问:

example.com/blog-1
它们将被重定向到:

subdomain.example.com/blog-1
我不想直接使用通配符,只使用我的博客URL列表

谢谢

这是我的重定向到https的中间件

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: https-only
  namespace: exmaple
spec:
  redirectScheme:
    scheme: https
    permanent: true
重定向是:

apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
  name: test-redirectregex
spec:
  redirectRegex:
    regex: "https://example.com"
    replacement: "https://subdomain.example.com"
    permanent: true
我可以在同一个中间件中使用多个redirectRegex吗?
然后,我会有很多它们来重定向每个url

每个中间件只有一个重定向,但是您可以有任意多个中间件

但在这种情况下,您可以使用正则表达式:

  redirectRegex:
    regex: "https://example.com/(blog-1|blog-2|whatever)"
    replacement: "https://subdomain.example.com/$1"

每个中间件只有一个重定向,但您可以拥有任意数量的中间件

但在这种情况下,您可以使用正则表达式:

  redirectRegex:
    regex: "https://example.com/(blog-1|blog-2|whatever)"
    replacement: "https://subdomain.example.com/$1"

哦,很好,正则表达式的长度有限制吗?Go的正则表达式库支持的语法记录在中。哦,很好,正则表达式的长度有限制吗?Go的正则表达式库支持的语法记录在中。