: Redirect/Rewrite Subdomain to Subfolder I'm trying to redirect a subdomain to a subfolder e.g. forums.domain.com to www.domain.com/forums Note that I started the forums in the subfolder format but
I'm trying to redirect a subdomain to a subfolder e.g. forums.domain.com to domain.com/forums
Note that I started the forums in the subfolder format but worried that members might mistakenly try to access the forums using the subdomain format.
RewriteCond %{HTTP_HOST} ^(www.)?forums.domain.com
RewriteRule .* /forums [L]
From what I read the codes above should work through .htaccess, but do I still need to create a DNS A record to point to the IP address of the server?
More posts by @Steve110
2 Comments
Sorted by latest first Latest Oldest Best
Without having to specify a domain in the circumstance that multiple domains point to the website root or that a production .htaccess rules can be applied to:
RewriteCond %{HTTP_HOST} ^(.*).ANYdomain.com [NC]
Try this:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^(www). [NC]
RewriteCond %{HTTP_HOST} ^(.*).domain.com [NC]
RewriteRule (.*) www.domain.com/%1 [R=301,L]
This is generic and will redirect all subdomains to a subdirectory. If you have only one subdomain you want to redirect you can hardcode it in.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.