我正在尝试弄清楚我的 .htaccess 应该是什么样子来执行以下操作:
获取任何看起来像
的网址{the protocol}thedomain.co.uk/home/{rest of uri}
或者
{the protocol}www.thedomain.co.uk/home/{rest of uri}
重定向到
{the protocol}subdomain.thedomain.co.uk/home/{rest of uri}
应该很简单,但我拥有 5 岁 child 的正则表达式技能。任何帮助表示赞赏。
最佳答案
将其添加到站点根目录的 .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]
关于php - 使用 .htaccess 根据文件路径的一部分重定向到新域?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28433373/