Hello folks,
I am a newbie in the area of domain management. I have some existing subdomains redirecting to some internet sites (not just to mine), work fine.
The problem is the rest of the non-existing subdomains, calling them I just get a kind of green Apache and Cpanel introduction page from my host company. I want to avoid this intro page, so in case of any non-existing subdomain I would like to have a redirection to (let's say) mydomain.com.
I have Cpanel and Apache, no virtual private server used. The existing subdomains have their own directories and .htaccess files under public_html directory, their rewrite code are similar to this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mysubdomain.example.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.mysubdomain.example.com$
RewriteRule ^(.*)$ http://www.targetdomain.com [R=301,L]
All the existing rewrites like the above are fine and working well.
My intension is to try to keep the mechanism above (as well as the different redirections of the existing subdomains) and redirect the non-existing subdomains to one domain only.
According to what I found in a topic viewtopi...5a242e 4f8641 , I tried similar to this code:
RewriteEngine on
RewriteRule ^(.*) http://www.test.com/$1 [P,L]
I placed my attempt into the .htaccess file of the root as well as the .htaccess file of the public_html, not working.
I only get the intro page of the host when calling non-existing subdomains. I think there should be a way to solve this problem, please help me. I tried to create several custom error handling pages, no way (but this area can also have a solution, I don't know).
Do you have any idea?
Thank you in advance,
jimmy