1

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!

  • If it helps, the server is on Amazon ec2 – Pasta Jan 20 '12 at 16:49
2

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]
  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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