Redirect multiple apache aliases to single url

Hi,

I have a site that has multiple apache aliases, so for example if you browser to sitec.com or www.siteb.com it is the same site as www.sitea.com handled by one enabled site in apache. I want to 301 redirect any site alias to www.sitea.com

I figure this can be done with .htaccess but I am not very good with creating the matching rules to get this working.

Thanks for your help.
LVL 17
jrm213jrm213Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PapertripCommented:
http://httpd.apache.org/docs/2.0/mod/mod_alias.html#redirect

Redirect permanent / http://www.sitea.com

Open in new window

0
jrm213jrm213Author Commented:
Won't that cause a problem? ie. www.sitea.com will also hit that redirect, so won't it create a redirect loop?

basically I have this in apache site config

ServerName www.sitea.com
ServerAlias sitea.com www.siteb.com siteb.com www.sitec.com sitec.com www.sited.com sited.com www.sitee.com sitee.com

Open in new window


Alll of the server alias domains, and server name domain all are the same apache site. But no matter which one you go to I want the url to show www.sitea.com, so if you had bookmarked www.sitec.com/page1  it would 301 redirect to www.sitea.com/page1

does that make sense?
0
PapertripCommented:
Yeah, my bad I overlooked the part of your question where you said you had aliases setup.  I will reply again after lunch, unless someone gets it before me.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

jrm213jrm213Author Commented:
Ok, no problem.

Thanks
0
PapertripCommented:
OK so if you want to keep all the ServerAlias entries instead of creating individual vhosts for them, then the following will work.
     RewriteEngine  on
     RewriteCond %{HTTP_HOST} !^www.sitea.com$ [NC]
     RewriteRule ^(.*)$ http://www.sitea.com/$1 [R=301,NC,L]

Open in new window


That is pretty basic and should be put into the VirtualHost config block where ServerName is listed.

Depending on how your website is configured (ie: aliases, .htaccess, Directory config blocks, etc), there could be some additional tuning required, but for "basic" 301 rewrites, that syntax will work just fine.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jrm213jrm213Author Commented:
Thanks, that worked for the aliases.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.