Search code examples
.htaccessdnshttp-status-code-301forwarding

How do I redirect a subdomain to a different domain?


How do I redirect this:

www.sub.example.com

to this:

www.example2.com

How is this done -- 301? .htaccess? Can someone point me in the right direction please? My host is NearlyFreeSpeech and the domain I want to redirect to is quite a large site with a static IP.


Solution

  • There are multiple ways to do this:

    Other solutions are possible, and generally vary by server and configuration stack. I assume Apache compliance, given the presence of .htaccess in the problem statement.

    Here's a Wikipedia reference on redirects via the 3xx family of HTTP status codes, if anyone's curious about the client's perspective.