เว็บนี้มีลิงก์ affiliate — หากสมัครผ่านลิงก์ เราได้รับค่าคอมมิชชัน · Affiliate links. รายละเอียด

Subdomain คืออะไร ใช้ทำอะไร ตั้งค่าอย่างไร

What is a Subdomain? Uses, how to create one, DNS settings, and when to use subdomain vs subdirectory.

Subdomain คืออะไร ใช้ทำอะไร ตั้งค่าอย่างไร
แนะนำAsiaGB.com — Web Hosting & VPS คุณภาพสูง พร้อมทีม Support ภาษาไทย 24 ชั่วโมง SSD NVMe uptime 99.9%

AsiaGB.com — Premium hosting & VPS with Thai support, NVMe SSD, 99.9% uptime.

เยี่ยมชม AsiaGB →

Subdomain คืออะไร

Subdomain คือส่วนหน้าของ Domain Name ที่แยกออกมา เช่น ถ้า Domain หลักคือ example.com แล้วมี blog.example.com, shop.example.com หรือ mail.example.com สิ่งเหล่านี้คือ Subdomain ชี้ไปที่ IP หรือ Server ที่แตกต่างกันได้

A subdomain is a prefix segment of a domain name. If the main domain is example.com, then blog.example.com, shop.example.com, or mail.example.com are subdomains — each can point to different IP addresses or servers.

Subdomain ใช้ทำอะไรได้บ้าง

Subdomain ใช้ได้หลากหลาย เช่น แยก Blog ออกจากเว็บหลัก, แยก E-commerce Store, ทำ Staging Environment สำหรับทดสอบ, ทำ API Endpoint, ทำ CDN ให้รูปภาพ, ทำ Mobile Version ของเว็บ, หรือแยก Regional Site

Subdomains have many uses: separating a blog from the main site, isolating an e-commerce store, creating staging environments for testing, API endpoints, CDN for images, mobile versions of websites, or regional sites.

Subdomain vs Subdirectory ต่างกันอย่างไร

Subdomain (blog.example.com) และ Subdirectory (example.com/blog) ต่างกันที่ Subdomain สร้าง Entity ใหม่แยกต่างหาก สามารถ Host บน Server ต่างกัน ใช้ CMS ต่างกันได้ Subdirectory ใช้ Server เดิม Config เดิม ง่ายกว่าในแง่ SEO

Subdomain (blog.example.com) vs Subdirectory (example.com/blog): subdomains create separate entities that can be hosted on different servers with different CMS. Subdirectories use the same server and configuration, and are generally simpler for SEO.

ตั้งค่า DNS สำหรับ Subdomain

สร้าง Subdomain โดยเพิ่ม A Record หรือ CNAME Record ใน DNS Zone ของ Domain ถ้า Subdomain ชี้ไป IP เดียวกับ Root Domain ใช้ A Record ชี้ IP เดียวกัน ถ้าชี้ไป Domain อื่น (เช่น CDN, GitHub Pages) ใช้ CNAME Record

Create a subdomain by adding an A Record or CNAME Record to the domain's DNS zone. If the subdomain points to the same IP as the root domain, use an A Record with the same IP. If pointing to another domain (CDN, GitHub Pages), use a CNAME Record.

ตั้งค่า Subdomain บน Hosting

ที่ cPanel หรือ DirectAdmin ไปที่ Subdomains Section เพิ่ม Subdomain ชื่อ เช่น blog และ Document Root เช่น /public_html/blog ระบบสร้าง Folder ให้อัตโนมัติ อัพโหลดไฟล์ไปใน Folder นั้น Subdomain พร้อมใช้งาน

In cPanel or DirectAdmin, go to Subdomains section, add the subdomain name (e.g., blog) and document root (e.g., /public_html/blog). The system automatically creates the folder. Upload files to that folder and the subdomain is ready.

Subdomain กับ SEO

Subdomain และ Subdirectory มีผลต่อ SEO แตกต่างกัน Google ถือว่า Subdomain เป็น Entity แยก บางกรณีต้องสร้าง Authority ใหม่สำหรับ Subdomain ในขณะที่ Subdirectory แชร์ Authority กับ Root Domain สำหรับ Blog หรือ Content ที่ต้องการ SEO ผล Subdirectory แนะนำกว่า

Subdomains and subdirectories affect SEO differently. Google treats subdomains as separate entities — sometimes requiring rebuilding authority. Subdirectories share the root domain's authority. For blogs or SEO-driven content, subdirectories are generally preferable.

Wildcard Subdomain

Wildcard Subdomain (*.example.com) รับ Request ทุก Subdomain ที่ไม่ได้ Define ไว้ ใช้สำหรับ Multi-tenant Application เช่น username.example.com หรือ customer.example.com ต้องตั้งค่า DNS Wildcard A Record และ Hosting รองรับ Wildcard

Wildcard subdomain (*.example.com) accepts requests for any subdomain not explicitly defined — used for multi-tenant applications like username.example.com or customer.example.com. Requires wildcard DNS A Record and hosting support for wildcards.

ตัวอย่างการใช้ Subdomain จริง

ตัวอย่าง Subdomain ที่นิยม: docs.example.com สำหรับ Documentation, status.example.com สำหรับ Status Page, app.example.com สำหรับ Web App, en.example.com และ th.example.com สำหรับ Multilingual Site, m.example.com สำหรับ Mobile Version

Popular real-world subdomain examples: docs.example.com for documentation, status.example.com for status pages, app.example.com for web apps, en/th.example.com for multilingual sites, m.example.com for mobile versions.

สรุปขั้นตอนสร้าง Subdomain

1. เพิ่ม DNS Record (A หรือ CNAME) ที่ DNS Provider 2. รอ Propagation 30 นาที - 24 ชั่วโมง 3. ตั้งค่าที่ Hosting (cPanel/DirectAdmin) 4. ขอ SSL Certificate สำหรับ Subdomain 5. ทดสอบว่า HTTPS ทำงานได้

Step-by-step: 1. Add DNS Record (A or CNAME) at DNS provider 2. Wait 30 min to 24 hours for propagation 3. Configure at hosting (cPanel/DirectAdmin) 4. Request SSL certificate for subdomain 5. Test HTTPS functionality.

คำถามที่พบบ่อย (FAQ)

Subdomain กับ Subdirectory อันไหนดีกว่าสำหรับ Blog?
สำหรับ Blog ของเว็บเดิม Subdirectory (example.com/blog) แนะนำกว่า เพราะแชร์ Authority ของ Root Domain ทำให้ SEO ดีขึ้นเร็วกว่า ยกเว้นต้องการ Blog บน Platform ต่างกัน เช่น WordPress บน Ghost ค่อยใช้ Subdomain
SSL สำหรับ Subdomain ต้องซื้อแยกไหม?
ขึ้นกับ SSL Type ถ้าซื้อ Wildcard SSL (*.example.com) ครอบคลุมทุก Subdomain Let's Encrypt ฟรีออก SSL ต่อ Subdomain ได้ ไม่จำกัด Wildcard SSL Let's Encrypt ก็มีแต่ต้องทำผ่าน DNS Challenge
Subdomain เดียวกัน Host หลาย Website ได้ไหม?
ไม่ได้โดยตรง Subdomain ชี้ไป IP/Server เดียว แต่ที่ Server นั้นสามารถมี Virtual Host หลายตัวต่อ IP เดียวได้ผ่าน Name-based Virtual Hosting ดังนั้นที่ IP เดียวมีหลายเว็บได้ แต่ Subdomain ชื่อเดียวชี้ได้ทีละที่
Subdomain มีผลต่อ Email ไหม?
Subdomain ไม่กระทบ Email หลัก ถ้า Email ใช้ mail.example.com เป็น MX Record ส่วน blog.example.com แยกกันคนละ Record DNS ไม่มีผลซึ่งกันและกัน แต่ถ้าต้องการ Email บน Subdomain ต้องตั้ง MX Record แยกด้วย