Drupal: Redirecting Subdomain To Site Domain
In this article, I would tell you a couple solutions of how you can set redirecting subdomain to the main site domain. One of the solutions will include using of an appropriate module.
Using of .htaccess file
Insert the following lines:
RewriteCond %{HTTP_HOST} ^www\.example\.com
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
to .htaccess (which is located in the site root) after this code:
<IfModule mod_rewrite.c>
RewriteEngine on
How it works:
- http://www.example.com → http://example.com
- http://www.example.com/* → http://example.com/*
Using of Toggle WWW module
If you have no access to .htaccess or web-server is not Apache, you can use a module that makes redirection of the kind:
http://www.example.com/some/deep/page → http://example.com/some/deep/page
Advantages of this method:
- increasing LinkRank (search engines increase LinkRank of a new page when redirecting)
- Old links still work
You can download & install the module from drupal.org.
Good luck!