DNS重定向域子域 [英] DNS Redirect domain to subdomain

查看:150
本文介绍了DNS重定向域子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找一种方式通过DNS A / CNAME记录重定向域的子域。

I am looking for a way to redirect a domain to its subdomain via DNS a / cname records.

是否有可能有这些例子做完全在DNS中,我知道它可以用的​​.htaccess和PHP很容易做到。

Is it possible to have these examples done totally in DNS, I know it can be easily done with .htaccess and PHP.

website.com => blog.website.com
website.com/hello => blog.website.com/hello
www.website.com => blog.website.com
www.website.com/hello => blog.website.com/hello

任何想法?

推荐答案

DNS仅用于域名与IP地址相关联。你不能做的重定向的吧。

DNS is only for associating domain names with an IP address. You cannot do a redirection with it.

您将不得不处理对Web服务器端的重定向。你只需要抛出一个HTTP 301永久移动来让你的访问者知道新的地址是否与的.htaccess 文件如果你使用的是Apache,或用头一个简单的PHP脚本()的功能。

You will have to handle the redirection on the web server side. You just need to throw an HTTP 301 Permanently moved to let your visitors know the new address whether with an .htaccess file if you are using apache, or a simple PHP script with an header() function.

这篇关于DNS重定向域子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆