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.