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 have the following on my .htaccess file within /var/www/html folder.

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.net [nc,or]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com\.au [nc,or]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent, NC, L]

I want all domain.net and domain.com.au requests to redirect to domain.com.

This does not seem to redirect. What am I doing wrong? Thanks!

share|improve this question
    
If it helps, the server is on Amazon ec2 –  Pasta Jan 20 '12 at 16:49

1 Answer 1

up vote 2 down vote accepted

In the past I've had trouble with spaces in the list of flags. Also, the last OR is not needed and may cause problems. Try this:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.net [NC,OR]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com\.au [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent,NC,L]
share|improve this answer
    
Thanks, but no luck with that! –  Pasta Jan 20 '12 at 17:07
3  
If you go to the other domains (.net, .com.au) are the results the same as going to www.domain.com? Are you certain .htaccess overrides are enabled with e.g. AllowOverride All? –  xofer Jan 20 '12 at 17:14
1  
I get this error on error_log, [alert] /var/www/html/.htaccess: RewriteRule: bad flag delimiters –  Pasta Jan 20 '12 at 17:42
    
I've never seen [R=permanent] before. Only [R=301]. –  Ladadadada Jan 20 '12 at 17:49
    
Sorry! I had spaces in mine [R=permanent, NC, L], changed to [R=permanent,NC,L]. Now it works GREAT! –  Pasta Jan 20 '12 at 17:50

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.