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

4 Answers 4

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

www.example.com
foo.example.com
foo.bar.example.com

and even

*.example.com
*.foo.example.com

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 '14 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 '14 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

Here is the solution:

open page on your domain folder

wp-admin\network\site-new.php     

replace

if ( preg_match( '|^([a-zA-Z0-9-])+$|', $blog['domain'] ) )

with

if ( preg_match( '|^([a-zA-Z0-9.-])+$|', $blog['domain'] ) )
share|improve this answer

Every domain will be acessible by

http://www.example.com and http://example.com

as

http://www.subdomain.example.com and http://subdomain.example.com

Including any subdomain, to solve this problem you just need do a 301 redirect to force your visitors to acess only. This will be good for your SEO and google ranking because your page rank is shared by prefix www. and non-www

For example: 10 strongly ranked sites links the page: www.example.com/page.html 5 strongly ranked sites links the page: example.com/page.html

Your pagerank points will be shared to 2 "differents" websites

How to solve, the best simple way:

Create a .htacess (or edit if you already have)

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

Your Answer

 
discard

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.