Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I recently went live with a new website and one of the departments on campus referred users to a virtual domain.

For example, www.ia.domain.com masked itself as its own website, which was really domain.com/ia

What I want to do, is redirect everyone who hits www.ia.domain.com, to go to domain.com/ia,

as well as www.ia.domain.com/faculty/ => domain.com/ia/faculty/

This is on a new box, so it does not have the original configuration.

The site is being run on Apache, using linux (rhel5).

I am unfamiliar with mod_rewrite. I have done 301 redirects, but I am unable to redirect a virtual sub-domain that way.

share|improve this question

4 Answers 4

up vote 1 down vote accepted

How about not using mod_rewrite and instead using the redirect statement.

#Virtual Host for IA sub web
<VirtualHost *:80>
   ServerName www.ia.domain.com
   ServerAlias <other domain names they want to associate with this directory; ex: ia.domain.com>
   Redirect permanent / http://www.domain.com/ia_new_web_location/
</VirtualHost>
share|improve this answer

You'll need a name-based virtualhost set up for www.ia.domain.com

Inside the virtualhost configuration block, the following rule for mod_rewrite should do the trick:

RewriteRule ^/(.*) http://domain.com/ia/$1 [R]
share|improve this answer

Here's what I expect would work, in your Apache configuration (/etc/httpd/conf.d or /etc/apache2/conf.d, a file named, for example, domain.com.conf):

This may need to be adjusted depending on what other Apache configurations you have, of course.

NameVirtualHost *:80
<VirtualHost *:80>
   ServerName www.ia.example.com
   ServerAlias ia.exmaple.com
   Redirect permanent /(.*) http://www.example.com/ia/$1
</VirtualHost>

<VirtualHost *:80>
   #  Your normal website configurations here
</VirtualHost>

Sean

share|improve this answer

if you want have a transparent redirection, try this :

rewriteCond %{HTTP_HOST} ^www.ia.domain.com
rewriteRule ^/faculty(.*) domain.com/ia/faculty$1 [P]

The apache server use proxy module (you need enable proxy module) to make a transparent redirection (no 301 or 302 http code)

share|improve this answer
    
Note that this is a proxy, so the address bar won't change, it will stay at the original URL. This doesn't seem to be what the original poster was asking. Also, the destination in the proxy should begin with "http://". Just to be clear on the terminology, it's probably better to call this a proxy not a "transparent redirection". –  Sean Reifschneider Sep 4 '09 at 5:40

Your Answer

 
discard

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.