Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I'm not even sure how to search for an answer to this question, so my apologies if already asked.

We have a subdomain setup on the server in the format eg.example.com. Some people are typing in www.eg.example.com. Is there a way of handling the pseudo-subdomain? If so, how?

share|improve this question

2 Answers 2

up vote 2 down vote accepted

The subdomain is nothing else than a DNS record applied to the root domain. If you consider the root domain example.com, any of the following is a valid subdomain


and even


Then way you create subdomains is creating a DNS record for them, regardless it's a single-level subdomain (foo.example.com) or multilevel subdomain (foo.bar.example.com).

You need to check if the DNS provider your domain is using (it can be either a specific DNS provider or your current registrar) offers you to create subdomains and if they allow multiple levels.

If not, you can switch to a DNS hosting service that offers you more advanced DNS features. Keep in mind that you don't necessarily need to change web hosting or registrar, you can easily point the name server to another DNS provider without transferring the domain.

share|improve this answer
Thanks. I have GoDaddy as the registrar, so I'll test. I'll accept your answer when SE allows -- says I have to wait 8 mins, lol. –  Jeremy Miller Jan 12 at 12:55
@JeremyMiller: It's probable that GoDaddy automatically created the www.eg.example.com A record in DNS at the time you created the eg subdomain. –  w3d Jan 12 at 15:55

I think you need a redirect in your .htaccess file (assuming you are using Apache server) to redirect from www.eg.example.com to eg.example.com

Use a 301 redirect. It will look like this:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\. [nocase]
RewriteRule .* http://eg.example.com%{REQUEST_URI}%{QUERY_STRING} [redirect=301,L]

The first line turns on the next following rewrite lines. The second line tests for host names that begin with 'www.' (and is case insensitive), e.g. will find both 'www' and 'WWW' and 'Www' The third line is the business line. If line 2 tests true, line 3 executes. It rewrites the URL that your user sent. It issues a redirect 301, which is permanent. And it exits, because of the 'L'. It also keeps any path and query intact (assuming that is what you want). The user's browser gets this redirect, as well as Google, DuckDuckGo, etc. And the user will see the line they typed changed into the correct URL.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.