首页 > 解决方案 > 将目录重定向到子域

问题描述

我根本想不通,有谁知道如何描述一个链接.htaccess

example.com/bedrijven/marketing-metrics/

marketing-metrics.example.com/

我在这个论坛上找到了这个,但这不是解决方案

RewriteRule ^(bedrijven/$1.*)$ https:///$1.example.com/ [R=301,L,NC]

有没有人可以帮忙?

标签: .htaccessmod-rewrite

解决方案


请尝试以下方法:

RewriteRule ^bedrijven/([^/]+)/$ https://$1.example.com/ [R=301,L,NC]

$1是对RewriteRule 模式中第一个捕获组(第一个参数)的反向引用,即。任何匹配的([^/]+). 正如您在示例中使用的那样,在RewriteRule 模式本身中使用这样的反向引用是没有意义的。


推荐阅读