Redirect multiple apache aliases to single url


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

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
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.


Redirect permanent /

Open in new window

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

basically I have this in apache site config


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, so if you had bookmarked  it would 301 redirect to

does that make sense?
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.
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.

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} !^$ [NC]
     RewriteRule ^(.*)$$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.

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.
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.