Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm running Apache 2 on Ubuntu and would like to forward all request on one subdomain to another.

Example: would forward to

I want to forward all requests (not just a few pages).

How would I set that up in my virtual hosts?

share|improve this question

2 Answers 2

up vote 1 down vote accepted
RewriteEngine on
RewriteCond %{HTTP_HOST} ^a\.example\.com
RewriteRule ^(.*)$$1 
share|improve this answer
Where does that code go? – Shpigford Mar 20 '10 at 4:14
Either in your <VirtualHost> section or in a .htaccess file, depending on how you have things set up. – EEAA Mar 20 '10 at 5:18

I really wonder why everybody always tries to solve those redirect problems with mod_rewrite rather than mod_alias.

Put the following line inside the container of

RedirectPermanent /
share|improve this answer
That won't redirect to as requested by the OP. – ceejayoz Mar 21 '10 at 1:31
Of course it will! Have you even tried it? – joschi Mar 21 '10 at 6:32
@ceejayoz: - if I could upvote joschi twice, I would. – pjmorse Oct 8 '12 at 1:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.