Question

The issue im getting is too many redirects.

I have a WAMP server that hosts a few sites, but I have a particular site with about 5 domains. I want them all to point to the correct website folder and all to be redirected to a single domain for SEO purposes. Here is what it looks like in the virtual hosts file:

<VirtualHost 50.62.82.101>
ServerAdmin info@hovaness.com
DocumentRoot "c:/wamp/www/example"
ServerName example.com
ServerAlias example.net www.example.com www.examples.net www.examples.com examples.com examples.net
ErrorLog "logs/example.com.log"

The htaccess file looks like:

RewriteEngine On
RewriteRule ^(.*)$ http://sellingwarriors.com/$1 [R=301,L]
RewriteBase /

Am I only supposed to have one or the other? I have also tried in the htaccess file:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*?).example(s?).(.*)$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
RewriteBase /

Any help is appreciated

Was it helpful?

Solution

You need to check for the hostname that you are redirecting to, otherwise it will continue to redirect:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top