Redirect/Rewrite Subdomain to Subfolder
Redirect/Rewrite Subdomain to Subfolder - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the Redirect/Rewrite Subdomain to Subfolder error on your web browser. Problem :
Solution :
We hope that this article has helped you resolve the redirects, htaccess, dns error in your web browsers. Enjoy browsing the internet uninterrupted!
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 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?
Try this:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %HTTP_HOST !^(www). [NC]
RewriteCond %HTTP_HOST ^(.*).domain.com [NC]
RewriteRule (.*) http://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.
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]
Comments
Post a Comment