Reputation: 13
Im updating my htaccess so I can redirect my .net and .org domains to .com, but but I get a "domain has a loop error".
Im sure the issue has to do with the redirect of non-www to www, but Im not sure how to combine all the code. Any ideas?
My goal is to: (1) Redirect non-www to www (already setup and works perfect)and (2) Redirect .net and .org domains to .com
HTACCESS:
##### RewriteEngine enabled - BEGIN
RewriteEngine On
##### RewriteBase set - BEGIN
RewriteBase /
##### Redirect non-www to www - BEGIN
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
##Redirect .net and .org to .com - BEGIN
RewriteCond %{HTTP_HOST} ^(www\.)?example\.org [OR,NC]
RewriteCond %{HTTP_HOST} ^(www\.)?example\.net [OR,NC]
RewriteCond %{HTTP_HOST} ^www\.example\\.com [NC]
RewriteRule (.*) http://example\.com/$1 [R=301,L]
NOTE: Both .net and .org domains are ALREADY pointing to the same IP so there is no issue here.
Upvotes: 1
Views: 21
Reputation: 784908
You can do all this in a single rule:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
RewriteCond %{HTTP_HOST} \.(org|net)$ [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
Upvotes: 1