Too many redirects with Virtual Host and htaccess [closed]
Asked Answered
H

1

8

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 [email protected]
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

Hypothermia answered 5/4, 2013 at 3:51 Comment(0)
T
6

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]
Totaquine answered 5/4, 2013 at 20:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.