douhui3330
douhui3330
2016-02-21 10:03

htaccess将子域重定向到没有子域的新域

已采纳

Almost there:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^forums\.resistance\.tk  [NC]
RewriteRule ^(.*) https://www.libertaire.net/$1 [L,R=301]

this will redirect http://forums.resistance.tk/message.php?t=7751 to https://www.libertaire.net/forums/message.php?t=7758 but i want https://www.libertaire.net/message.php?t=7758

how can i achieve this?

thanks

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dougan4884 dougan4884 5年前

    In order to remove /forums/ while redirecting use this rule:

    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} ^forums\.resistance\.tk$  [NC]
    RewriteRule ^forums(/.*)?$ https://www.libertaire.net$1 [L,R=301,NC]
    

    Make sure to clear your browser cache before testing this.

    点赞 评论 复制链接分享