Sure, use a directive like:
<VirtualHost *:80>
ServerName www.subdomain.example.com
Redirect permanent / http://subdomain.example.com/
</VirtualHost>
Apache automatically preserves anything after the /
when using the Redirect
directive, which is a common misconception about why this method won't work (when in fact it does).
Also, yes you will need to change DNS records, because www.subdomain.example.com
is a distinct hostname that needs its own A (or CNAME) record to point the browser to an appropriate server in the first place.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…