【发布时间】:2021-04-08 08:11:08
【问题描述】:
我通过 helm chart 安装了 traefik。
我有一个域:example.com
它有一些博客文章。
我现在创建了一个子域:subdomain.example.com
我有我的博客网址列表:
/blog-1
/blog-2
基域和子域都在同一个集群上。
我想要 301 重定向,这样如果有人尝试访问:
example.com/blog-1
他们将被重定向到:
subdomain.example.com/blog-1
我不想只用我的博客网址列表直接使用通配符。
谢谢
这是我重定向到 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 吗? 然后我会有很多重定向每个网址
【问题讨论】:
标签: redirect kubernetes traefik http-redirect