Forum Moderators: phranque
I talked the support at the hosting site. He said the RedirectMatch 301 is wrong but how do I set this right? Thanks.
In zone db file:
; Host aliases here
;
DNSMANAGER IN A xx.xx.xx.xx
www IN CNAME @ ;1
mail IN CNAME @ ;2
smtp IN CNAME @ ;3
pop IN CNAME @ ;4
ftp IN CNAME @ ;5
* IN CNAME @ ;6
In httpd.conf:
<VirtualHost xx.xx.xx.xx>
ServerAlias *.mysite.com
RedirectMatch 301 (.*) [mysite.com$1...]
</VirtualHost>
In .htaccess:
IndexIgnore *
DirectoryIndex default.php
php_flag register_globals on
RewriteEngine on
RewriteCond %{HTTP_HOST}!^(www\.)?mysite\.com [NC]
RewriteCond %{HTTP_HOST} ^(.*)\.mysite\.com [NC]
RewriteRule .* /default.php?refid=%1 [L]
$urlarray = explode('.', $_SERVER['HTTP_HOST']);
$refid = $urlarray[0];
Welcome to WebmasterWorld [webmasterworld.com]!
Your RedirectMatch will redirect anything to the specified domain using a 301 external redirect. So, the server sends a reply to the browser saying, "That content has moved, use this new URL to get it." The browser will then issue a new request using that URL. The new request arrives, and because it matches the pattern in RedirectMatch, the process repeats.
If the goal is to redirect a specific domain name variant to a single domain, then use mod_rewrite and specify the domain name to be redirected. That way, the redirect will only take place if a request is received which uses the wrong domain name. If you don't qualify the redirect, the browser and server will do a redirect dance "forever" until one or the other times out.
Jim