canonicalization from root to subdomain

MentaL

Well-known member
Hi,

I've got a bunch of URLs indexed as

domain.com/forum.domain.com/threads/something

but it should be redirecting to the below url when accessed from the search engine

forum.domain.com/threads/something

I've got board URL canonicalization enabled and any links on that loaded page redirect to the subdomain but is there a prefered method to force the redirect via htaccess? Any rewrite rules set has been met with issues.

Regards
 
Fixed

Code:
# Rewrite domain.com/forum.domain.com to subdomain
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteCond %{REQUEST_URI} ^/forum\.domain\.com/(.*) [NC]
RewriteRule ^ https://forum.domain.com/%1 [R=301,L]
 
Back
Top Bottom