Hello everyone,

If I was to set my site to redirect any subdomain to the main page in the htaccess file like so:

RewriteCond %{HTTP_HOST} ^(.*).example.com 
RewriteCond %{HTTP_HOST} !^www.example.com [NC] 
RewriteRule ^(.*)$ http://www.example.com/ [P]

Would this mean that if I was to type in elephant.example.com it would redirect and show www.example.com in the address bar or would it stay showing elephant.example.com?

If it's the former, is there a way to make it so it stays displaying elephant.example.com so that I can redirect it to a folder or would it be better to make the index file of the site check the address of the site and use include to display the necessary page?

So if you do indeed remember correctly, if I was to remove the [P] flag then it would show www.example.com.

I have another query:

If I was to change my DNS settings so *.example.com would go to my site, would that affect any subdomains I have already set, such as blog.example.com or mail.example.com or would that only affect subdomains that haven't been declared, so to speak?

Yes.

Can't answer that one, have never tried it. Hopefully someone else can help you.

I would try it myself but my site is currently offline and I likely won't be able to get back online for quite a while.

Thanks for your help with my first question. Hopefully someone else can answer my second.

I can give you the answer that I received to a similar thread just a couple days ago.

apparently if you use cPanel, you can set up the *.domainname.com but you need to remove all other sub-domains first, because it will take ALL subdomain requests and redirect them.

BUT, what I have discovered is that it doesn't work if you use WHM instead of cPanel.

through WHM, there is no way to designate '*' as a valid sub-domain name.

Don't understand or even know why the difference based on control panels.

Hope that helps. Just trying to pass on the info I got, and still don't have a resolution to my own dilema...

here is a link to the thread I am referring to if you want to look at it.

http://www.daniweb.com/forums/thread321420.html


Doug

Thanks Doug but that doesn't help me. I'm not using any form of control panel or content management system. I'm going to mark this thread as solved since my original question was answered and I'll create a new thread for my second.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.