Forum Moderators: phranque

Message Too Old, No Replies

Urgent: sub-domain redirecting error

zone db, httpd.conf, .htaccess

         

bxy11

2:47 am on Jan 20, 2004 (gmt 0)

10+ Year Member



I'm redirecting all subdomains to the default.php under the root directory. Here's what I've in the zone db, httpd.conf and .htaccess files. It's been working for a while but now the site is brought down. The access_log file has tons of entries of
"GET / HTTP/1.1" 301 327

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]

bxy11

2:52 am on Jan 20, 2004 (gmt 0)

10+ Year Member



When this was working, I could type abc.mysite.com and then be redirected to the default.php under the root. Since the URL, abc.mysite.com stays, I do not use the parameter refid at all. Instead, I use the following code to get the $refid. In this case, $refid = "abc"
Thanks.

$urlarray = explode('.', $_SERVER['HTTP_HOST']);
$refid = $urlarray[0];

jdMorgan

3:25 am on Jan 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



bxy11,

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

bxy11

3:36 am on Jan 20, 2004 (gmt 0)

10+ Year Member



Thanks for the reply. I'll try that.

If I keep my .htaccess and zone db, but remove the VirtualHost from httpd.conf, will that work for my purpose? Thanks again for your help!

jdMorgan

3:46 am on Jan 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



bxy11,

Looking at the code you've got, I *think* all you need to do is to delete the RedirectMatch directive.

Jim

bxy11

3:55 am on Jan 20, 2004 (gmt 0)

10+ Year Member



Jim,

I took out the VirtualHost part from httpd.conf and keep the other two the same. I'm re-starting the server to see if the site can get back to normal and respond to requests. Thanks so much for your help!

bxy11

9:36 pm on Jan 21, 2004 (gmt 0)

10+ Year Member



Jim,

Now everything seems working fine. I don't get millions of the same message in the access log. Thanks so much for the help!