Can cPanel treat www.example.com as a separate subdomain?
-
Not that I am aware but I'll be interest to hear if it's possible. 0 -
I found a partial answer: Use cPanel > Redirects. Set "https?://(www.)?" to ** All Public Domains **. Set "www redirection" to "Redirect with or without www.". Click Add. Now URLs like "example.com" will be redirected to "www.example.com". This is done internally by adding [CODE=apacheconf]ServerAlias www.example.com
to the virtual host for domain example.com, so it is faster than using the rewrite engine. Just one thing I don't understand: why does a full redirect occur just because a ServerAlias is used? ServerAlias is not documented as triggering a Redirect.0 -
The redirect is in the htaccess. By having the server alias in the config Apache then knows what the home folder and user are among other things and then it knows what htaccess file to read. I must have misunderstood your question. I thought you wanted www to show different content than non-www without using the rewrite option. 0 -
No, you didn't misunderstand the original question. I piggy-backed. Sorry for the confusion. If I could separate example.com and www.example.com as two different virtual hosts, then a simple Redirect forces all users to use the desired domain name without needing .htaccess or rewrite engine. It works on my non-cPanel development site. 0
Please sign in to leave a comment.
Comments
4 comments