Can I redirect a subdomain to a different site using DNS or .htaccess?
We just moved mail servers for a website. We use Plesk as an interface on an Apache server.
mail.example.com used to be the name for the mail server, but it is no longer the case.
We want mail.example.com to now forward to the new web mail address http://webmail.com/xxx/example.com
Since this subdomain doesn't really exist in any sense anymore, is there any way I can use DNS records, or .htaccess to redirect mail.example.com to http://webmail.com/xxx/example.com?
The only way I can think of to do this is set up the subdomain in Plesk with no content except for a .htaccess file that will redirect all requests to the d开发者_运维技巧esired site. I really do not want to have a 'fake' subdomain set up just for redirecting purposes.
Does anyone have any suggestions on how to do this?
DNS cannot do an HTTP redirect. That's like asking a phone book to order you a pizza. You'd still need to have a website configured for the mail.example.com hostname, and have the webserver redirect to the new address. In Apache it's trivial (going off the top of my head for the syntax):
<virtualhost *:80>
servername mail.example.com
redirect permanent http://webmail.com/xxx/example.com
</virtualhost>
Another option would be to have the DNS record for mail.example.com simply serve up the IP address of the webmail.com site. But then you'd need to configure that site to accept the mail.example.com as an alias and do a redirect there so the user sees the new address.
精彩评论