使用.htaccess基于部分文件路径重定向到新域


Redirect based on part of filepath to new domain with .htaccess?

我正试图弄清楚我的.htaccess应该如何完成以下操作:

获取任何看起来像的url

{协议}domain.co.uk/home/{剩余的uri}

{协议}www.thedomain.co.uk/home/{剩余的uri}

重定向到

{协议}子域.tidomain.co.uk/home/{剩余的uri}

应该很简单,但我有一个5岁孩子的正则表达式技能。感谢您的帮助。

将其添加到站点根目录的.htaccess文件中。

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www'.)?thedomain'.co'.uk [NC]
RewriteCond %{HTTPS}s ^on(s)|off 
RewriteRule ^(home/.*)$ http%1://subdomain.thedomain.co.uk/$1 [R=301,L]