Use www prefix with subdomain


Browse by products and services

  • Applies to: DV
    • Difficulty: Medium
    • Time Needed: 10
    • Tools Required: root access, vi knowledge
  • Applies to: DV 4.0
    • Difficulty: Medium
    • Time Needed: 10
    • Tools Required: root access, vi knowledge

Overview

Generally, the www prefix is not used when using subdomains. If you want to use the prefix with your subdomain, you can make a vhost file and add this behavior as part of your domain configuration. See below for more information on how to do this.

Requirements

Before you start, this article has the following dependencies:

READ ME FIRST

This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.

Instructions

To create a www prefix for subdomains, you need to take the following steps:

  1. Create a vhost.conf file in the /var/www/vhosts/system/example.com/conf/ directory with the following content:
    ServerAlias www.sub.example.com
  2. Add an appropriate A record to the DNS zone of the domain in Server->Domains->example.com->DNS (specify this domain's IP address instead of 192.168.1.1):
    www.sub.example.com. A 192.168.1.1
  3. Run httpdmng utility to apply changes via SSH.
    /usr/local/psa/admin/sbin/httpdmng --reconfigure-domain example.com