ofen

Registered
Mar 8, 2014
2
0
1
cPanel Access Level
DataCenter Provider
I am Brazilian and I am using a translator.
For the purpose of redirecting to the main page of a website that users enter wrong its domain. I created some subdomains like w.domain.com, wwww.domain.com, ww.domain.com, etc.
However, when trying to create a www.www.domain.com for this same purpose I got the following response: "Sorry, www cannot be used in subdomains. It is implicitly added to all newly created subdomains. ".
Wondering what the www is a subdomain created automatically and therefore the www.www should work, I created the DNS entries for the www.www.domain.com, and to work around the problem in cPanel subdomains I created the *. www.domain.com (with wildcard), still I did not succeed. The server to answer now, but I don't understand to what folder inside the subdomain points.
See an example:
- removed -

To me this seems to be a bug. An unexpected situation.
I appreciate any help.
 
Last edited by a moderator:

robb3369

Well-Known Member
Mar 1, 2008
122
1
68
cPanel Access Level
Root Administrator
Actually www is not a sub-domain that is added, its a cname record that point to the domain name...

I think to address your issue, you can go into cPanel and add a sub-domain with an * (asterisks) so the sub-domain is *.domain.com and points to the /public_html/ directory...

Now, in your site's .htaccess file, use something like this:
Code:
<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteBase /
	RewriteCond %{HTTP_HOST} !^www\.domain\.com
	RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L] 
</IfModule>
That will redirect the user to www.domain.com site, regardless of what sub-domain they typed into the browser to get there...
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
I am happy to see the solution provided was helpful. Thank you for updating us with the outcome.