我通过舵图安装了traefik。
我有一个域名:example.com
它有一些博客文章。
我现在创建了一个子域:subdomain.example.com
我有我的博客网址列表:
/blog-1
/blog-2
基域和子域都位于同一集群上。
我想要301次重定向,这样如果有人试图访问:
example.com/blog-1
它们将重定向到:
subdomain.example.com/blog-1
我不想用通配符直接使用我的博客urls列表。
谢谢
下面是我的重定向到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
发布于 2021-01-01 20:12:17
每个中间件只有一个重定向,但是您可以拥有任意数量的中间件。
但是在这种情况下,您可以使用regex:
redirectRegex:
regex: "https://example.com/(blog-1|blog-2|whatever)"
replacement: "https://subdomain.example.com/$1"
https://stackoverflow.com/questions/65530404
复制相似问题