Htaccess 重定向 :将子域转换为 url 的一部分


Htaccess Redirect : convert subdomain to part of a url

例如,我的域是www.mydomain.com我有像这样的子域subdomain.mydomain.com/action?qs1=1

现在我已将以前的子域 URL 更改为www.mydomain.com/subdomain/action?qs1=1

请让我知道如何在htaccess中编写规则以进行重定向

subdomain.mydomain.com/action?qs1=1

www.mydomain.com/subdomain/action?qs1=1

谢谢

这应该有效:

RewriteEngine on

RewriteCond %{HTTP_HOST} ^((?!www).+)'.example.com$
RewriteCond %{THE_REQUEST} /action/'?qs1=1 [NC]
RewriteRule ^ http://www.example.com/subdomain/action/ [NC,L,R]