htaccess: multiple redirections depending on domain name

Posted by Marcin Kmiec on Server Fault See other posts from Server Fault or by Marcin Kmiec
Published on 2012-11-29T09:51:35Z Indexed on 2012/11/29 17:07 UTC
Read the original article Hit count: 275

Filed under:

I have a server and a few domains and two webpages. Can't figure out how to do the following:

A.com -> root\
www.A.com -> root\
B.com -> root\
www.B.com -> root\
C.com -> root\folder1\
www.C.com -> root\folder1\

By the way. What is the 'and' logical operator used in htaccess? I found that 'or' is [OR] but [AND] doesn't seem to work. And what is the language htaccess is written in:)?

UPDATE

I made a mistake in the question though. Here's what I'd really want to do. DNS is set for the domain A.com to point to the root folder of the server. Now I would like to set the following redirections:

Any domain other than C.com and other than D.com redirects (301) to www.A.com. A.com points to the root folder of the server anyway and that is set in DNS.

Domain www.C.com points to the folder 'folder1' on the server. Can it be set in htaccess?

Now domains C.com, www.D.com and D.com redirects to www.C.com.

© Server Fault or respective owner

Related posts about .htaccess