DNS Redirect domain to subdomain(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 Permanentlymoved 让你的访问者知道新地址,如果你使用的是 .htaccess 文件,或者一个简单的 PHP 脚本,一个 header() 函数.
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 将域重定向到子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:DNS 将域重定向到子域
基础教程推荐
- 如何替换eregi() 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
