Ужасно записанный вопрос, но;
Я - огромный поклонник диапазона P2000, но никогда не находил использование для версии SAS - для чего Вы планируете использовать его? Я просто немного путаюсь/касаюсь любой кластерной функциональностью, которую можно иметь в виду.
Похоже, вы почти у цели, не так ли?
Используйте RewriteCond на основе REMOTE_ADDR, например:
#
# Provide HTTP redirect "[R]" for network-external requests
# For permanent redirects, use [R=301], but note cache concerns:
# http://getluky.net/2010/12/14/301-redirects-cannot-be-undon/
#
RewriteCond %{REMOTE_ADDR} !^10\.2\.
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{REQUEST_URI} ^/foo/.*$ [NC]
RewriteRule ^/foo/(.*)$ http://foo.example.com/$1 [R]
#
# Pass-Through "[PT]" to subpath URL for subdomain requests
# (Assumes that foo.example.com/foo would serve the same
# content as example.com/foo, if not for the above rule)
#
RewriteCond %{HTTP_HOST} ^foo\.example\.com [NC]
RewriteRule ^/(.*)$ /foo/$1 [PT]
Пример использования совпадения в REMOTE_ADDR с адресами 10.2.xx: из http://httpd.apache.org/docs/2.2/rewrite/intro.html
Я подозреваю, что вам нужно использовать «PT» из-за наличия псевдонима где-то еще в вашей конфигурации. Или непрямой VirtualHost DocumentRoot.
В любом случае, в моем тестировании это помогло:
<VirtualHost _default_:80>
DocumentRoot /var/www/html
RewriteEngine on
RewriteCond %{HTTP_HOST} ^foo\.localhost [NC]
RewriteCond %{REQUEST_URI} ^/foo/.*$ [NC]
RewriteRule ^/foo/(.*)$ /$1 [R]
RewriteCond %{HTTP_HOST} ^foo\.localhost [NC] # <---
RewriteCond %{REQUEST_URI} !^/foo/.*$ [NC] # AND is implicit with above
RewriteRule ^/(.*)$ /foo/index.php?q=$1 [PT]
</VirtualHost>
Со следующим выводом:
$ curl -D - foo.localhost / index.php
HTTP/1.1 200 OK
Date: Wed, 06 Nov 2013 13:46:45 GMT
Server: Apache/2.2.17 (Fedora)
Vary: Host
X-Powered-By: PHP/5.3.6
Content-Length: 55
Connection: close
Content-Type: text/html; charset=UTF-8
Host: foo.localhost
URI: /index.php
Query: q=index.php
$ curl -D - foo.localhost / foo / index.php
HTTP/1.1 302 Found
Date: Wed, 06 Nov 2013 13:46:51 GMT
Server: Apache/2.2.17 (Fedora)
Location: http://foo.localhost/index.php
Content-Length: 293
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://foo.localhost/index.php">here</a>.</p>
<hr>
<address>Apache/2.2.17 (Fedora) Server at foo.localhost Port 80</address>
</body></html>
$ curl -D - foo.localhost / something
HTTP/1.1 200 OK
Date: Wed, 06 Nov 2013 13:46:59 GMT
Server: Apache/2.2.17 (Fedora)
Vary: Host
X-Powered-By: PHP/5.3.6
Content-Length: 53
Connection: close
Content-Type: text/html; charset=UTF-8
Host: foo.localhost
URI: /anything
Query: q=anything
$ curl -D - foo.localhost / foo / something
HTTP/1.1 302 Found
Date: Wed, 06 Nov 2013 13:47:04 GMT
Server: Apache/2.2.17 (Fedora)
Location: http://foo.localhost/anything
Content-Length: 292
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://foo.localhost/anything">here</a>.</p>
<hr>
<address>Apache/2.2.17 (Fedora) Server at foo.localhost Port 80</address>
</body></html>