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!

link|improve this question

73% accept rate
If it helps, the server is on Amazon ec2 – Pasta Jan 20 at 16:49
feedback

1 Answer

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]
link|improve this answer
Thanks, but no luck with that! – Pasta Jan 20 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 at 17:14
1  
I get this error on error_log, [alert] /var/www/html/.htaccess: RewriteRule: bad flag delimiters – Pasta Jan 20 at 17:42
I've never seen [R=permanent] before. Only [R=301]. – Ladadadada Jan 20 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 at 17:50
feedback

Your Answer

 
or
required, but never shown

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