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'm trying to write my mod_rewrite rules in my .htaccess file to fix the URL that shows up in the browser bar when visitors to to my site. I have a few options that I want my users to be able to enter. They should be able to enter something like:

aaa.xxx.yyy.edu
bbb.xxx.yyy.edu

and it should forward to

bbb.org

where bbb.org is a URL that I own that's pointing to the site now. I've already got a rule that removes www. from the front of either of those, and I have a rule that will forward aaa.xxx.yyy.edu to bbb.xxx.yyy.edu, but if you go to bbb.org, the URL in the browser bar shows up as bbb.xxx.yyy.edu.

Any suggestions?

share|improve this question

2 Answers 2

up vote 0 down vote accepted
<IfModule mod_rewrite.c>
  RewriteEngine on

  RewriteCond %{HTTP_HOST} ^(www\.)?(aaa|bbb)\.xxx\.yyy\.edu$ [NC]
  RewriteRule ^(.*)$ http://bbb.org$1 [L,R=301]
</IfModule>
share|improve this answer
    
Excellent, thanks! –  Kyle Oliveira Apr 27 '12 at 17:36

Use Redirect instead:

Redirect Permanent / http://bbb.org/

Put this inside a vhost that responds to both the hostnames:

<Virtualhost *:80>
 ServerName aaa.xxx.yyy.edu
 ServerAlias bbb.xxx.yyy.edu
 Redirect Permanent / http://bbb.org/
</Virtualhost>
share|improve this answer

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.