Would the following lines function?
For a given definition of "function". Did you intentionally leave off all flags in order to strip the question to its bare minimum, or is the absence of flags part of the question?
When there is no [L] (or L-equivalent such as [F] or [G]) then mod_rewrite will continue looking for other things to do. It's counter-intuitive, but a redirect doesn't carry an automatic [L]. There is a more serious issue but I'll get to that.
2) What options are available in the first part of the RewriteRule (i. e., .*)
As you know from other threads, an all-encompassing .* in the Pattern is a last resort. Use it only when the offender might ask for any file of any kind. Most RewriteRules can be constrained to requests for a particular filetype, like pages or images. You do this by using anchors: ending $ and possibly beginning ^ in combination with some literal text.
Request for front page only:
!. in htaccess (meaning "the empty request"-- a rare case of using ! in the pattern)
^/$ in config file
Request for any other page, if site uses extensions (here I use .html as an example):
(/|\.html)$
Request for either in htaccess
but don't quote me on this one:
^([^.]+(/|\.html))?$
Request for page, if site doesn't use extensions:
^([^.]*)$
(will not work on ::cough-cough:: sites like apache dot org, because they will have literal . in the body of their URLs so you have to get more complicated)
Request for image:
\.(jpe?g|png|gif)$
3) Exactly what does the rule, as written, do?
You didn't ask this, but it seemed best to include it for completeness.
Every time a request of any kind is received
.* in RewriteRule
look at Conditions. If the request is for a file whose full name begins
testingXexampleXcoXuk
(with possibility of following port number, but nothing before "testing") where X means "any single character of any kind" then proceed to the second Condition. In practice this will be testing.example.co.uk simply because no other request will reach the server, so in this isolated case the . for \. error is not lethal.
Second Condition: If the request is coming in from a place whose IP does not begin with "012.345" (I assume that was made up, since multi-digit IP segments don't have leading zeros) OR does not begin with "123.456" then execute the rule.
Since anything in the form "not A OR not B" will always apply-- assuming A and B are the same type of information, as they are here-- this Condition will always be met. So the only true Condition is the HTTP_HOST one. ("not-A or not-B" is not the same thing as "not {A or B}" i.e. "not-A AND not-B")
I suspect however that those ! in the Conditions sneaked in behind your back, and what you really meant was "IS either A or B". Or, conversely, the OR is a mistake and you meant "is not A AND ALSO is not B". I should also assume that you forgot to escape the literal periods in the first Condition. Like all computers, Apache is fairly stupid and can't tell the difference between a typo and a real mistake, or between either one and the author's intention.
Quick edit: Oops, almost forgot to say what the Rule does in the end. It takes all requests aimed at testingXexampleXcoXuk and sends them to the front page of www.example.com
[edited by: lucy24 at 12:04 am (utc) on Sep 30, 2012]