简体   繁体   中英

htaccess redirect subdomain to new domain WITHOUT subdomain

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM