views:

26

answers:

2

At this time every site on my server is on the domain "mydomain.com" or "subdomain.mydomain.com", I do various re-writes depending on the subdomain used to access the site.

What I want to do now, is send any request NOT from my domain or subdomains to a script for handling...... sounds simple, but I can't get it working..

This is what I have:

RewriteEngine on
RewriteCond %{ENV:Rewrite-Done} !^Yes$
RewriteCond %{HTTP_HOST} !^(.*)\.mydomain\.com
RewriteRule (.*) /_testing/htaccess/off.php?$1

It correctly lets any traffic on my domain or subdomain through, but gives a 500 internal server error on the re-write. Am I missing something obvious?

A: 

Try this rule:

RewriteCond %{HTTP_HOST} !^(.+\.)?example\.com$
RewriteCond $1 !=/_testing/htaccess/off.php
RewriteRule (.*) /_testing/htaccess/off.php?$1
Gumbo
Hi Gumbo, I'm gettin the same results as my version, works fine on my domain and subdomains but errors 500 when it is supposed to rewrite.I'm struggling to enable logging at the moment, hopefully that will yeild some answers.
Jenkz
A: 

It turned out that the htaccess rule was redirecting indefinitely. This was because my handler script was inside the /htaccess/ directory itsself.

I've moved the handler file to another location and this now works:

RewriteEngine on
RewriteCond %{ENV:Rewrite-Done} !^Yes$
RewriteCond %{HTTP_HOST} !^(.+\.)?example\.com$
RewriteRule (.*) /_testing/get.php?http_host=%{HTTP_HOST}
Jenkz