大网数据广告活动
网站运营与故障问答

Point DNS to VPS IP address on Namecheap

· 52CE 我爱测

I own a domain through Namecheap and a VPS with Linode. I would like to point my domain at the vps ipaddress. So far I have added the following: TYPE HOST VALUE TTL A + Dynamic DNS Record www vps ipaddress Automatic Im a little c…

问题原文

原帖链接 · darkpool · CC BY-SA 3.0

I own a domain through Namecheap and a VPS with Linode. I would like to point my domain at the vps ipaddress. So far I have added the following:

TYPE                     HOST    VALUE           TTL
A + Dynamic DNS Record    www    vps ipaddress   Automatic

Im a little confused as to whether the above is correct or should I have just selected A Record instead of A + Dynamic DNS Record (not sure of the difference).

Also, do I need to change the following so that VALUE equals my domain:

TYPE            HOST    VALUE                        TTL
CNAME Record    www     parkingpage.namecheap.com    30min

or do I need to add an additional CNAME Record with my domain and leave the existing one as is. I've read through this but am not entirely sure if I need to do anything: link

Lastly, there is already a line item for:

TYPE                  HOST    VALUE                             TTL
Url Redirect Record   @       http://www.example.com  unmasked

Does the above mean that people typing in www.example.com or just http://example.com will both get directed to the www version?

UPDATE:

I've managed to make some progress. My complete list of A Records are now as follows:

TYPE         HOST    VALUE            TTL
A Record     @       vps ipaddress    Automatic
A Record     www     vps ipaddress    Automatic

If I ping www.example.com I can see that it is pinging my ip adress on linode servers. However if I try ping example.com then it just hangs. So the www part is working. How do I get the the non www version to also work?

已采纳解答

原帖链接 · L Martin · CC BY-SA 3.0

Here's the setup you want:

  1. An 'A Record' pointing to your VPS server IP. In this case, example.com. Or: "A Record | @ | VPS IP address"
  2. A Cname record stating the subdomain (www) is the same as the root version (@). Or: "Cname Record | @ | www.example.com". This means when someone looks up 'www.example.com' it redirects them to the A record for 'example.com'
  3. Remove other A or Cname Records with @ or www in them as a 'Host'. These are conflicting with the first two directives.

Now make sure your host is configured to respond to both www.example.com and example.com in it's config. Redirect the example.com requests to www.example.com using a 301 redirect in Apache/Nginx/IIS. An example Apache setup using the rewrite module would be:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

It's generally a bad idea to cname your root (@) domain if you're using subdomains. This could save you a headache in the future. You can also set up two A records (one for www, one for @) but then when you change the IP it means changing both. A Cname makes it look up another record - so you only need to change one. This is just good practice but your method of setting two A records works fine.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2017-02-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。