作者:XL | 来源:互联网 | 2023-01-05 18:59
Onmywebsite,Iaminterestedinmovingmyforumsfromasubdirectorytoasubdomain.Theforumsar
On my website, I am interested in moving my forums from a subdirectory to a subdomain. The forums are currently located at example.com/forums
, and I want to move them to forums.example.com
. After the move, I want to use htaccess to 301 redirect all forum traffic to the subdomain, but the problem is that I have two TLDs for my site, a .com
domain and a .net
domain.
在我的网站上,我有兴趣将我的论坛从子目录移动到子域。论坛目前位于example.com/forums,我想将它们移到forums.example.com。移动后,我想使用htaccess 301将所有论坛流量重定向到子域,但问题是我的网站有两个TLD,.com域和.net域。
I am currently trying to redirect traffic using this:
我目前正在尝试使用以下方法重定向流量:
RewriteCond %{HTTP_HOST} !=forums.example.net
RewriteRule ^forums(/(.*))?$ https://forums.example.net/$2 [L,R=301]
RewriteCond %{HTTP_HOST} !=forums.example.com
RewriteRule ^forums(/(.*))?$ https://forums.example.com/$2 [L,R=301]
This only half-works. Regardless of which TLD I visit, it always redirects me to forums.example.net
, even if I am visiting from example.com/forums
, in which case I want it to go to forums.example.com
. How could I achieve this?
这只有一半的作品。无论我访问哪个TLD,它总是将我重定向到forums.example.net,即使我从example.com/forums访问,在这种情况下我希望它转到forums.example.com。我怎么能实现这个目标?
2 个解决方案