Ok! Depois de ter movido ambos para seus subdiretórios, você pode fazer algo assim:
<VirtualHost *:80>
ServerName example.com
# .. any other needed config, logging, etc
# Yes, you'll leave this at the parent directory..
DocumentRoot /var/www/public_html
<Directory /var/www/public_html>
Order Allow,Deny
Allow from all
RewriteEngine On
# Let's prevent any rewrite of anything starting with new or old,
# to head off potential internal redirect loops from pass-thrus..
RewriteRule ^(new|old) - [L]
# Here's where we'll handle the logic.
# This will vary the page based on IP address.
# If the user is in the 10.0.0.0/8 address range...
RewriteCond %{REMOTE_ADDR} ^10\..*$
# ...then we'll give them the new page.
RewriteRule ^(.*)$ new/$1 [L]
# Otherwise, we'll give them the old page.
RewriteRule ^(.*)$ old/$1 [L]
</Directory>
</VirtualHost>
Você pode acionar qualquer coisa que mod_rewrite
possa ver. Para cookies, troque-o para a parte em Here's where we'll handle the logic.
acima:
RewriteCond %{HTTP_COOKIE} newsite=true
# Client sent a cookie with "newsite=true"
RewriteRule ^(.*)$ new/$1 [L]
# No matching cookie, give them the old site
RewriteRule ^(.*)$ old/$1 [L]
Ou GET
de parâmetros de consulta de solicitação:
RewriteCond %{QUERY_STRING} newsite=1
# Client sent /path/to/page?newsite=1 - give them the new one
RewriteRule ^(.*)$ new/$1 [L]
# Fall back to the old one
RewriteRule ^(.*)$ old/$1 [L]
Ou para ambos ..
RewriteCond %{QUERY_STRING} newsite=1 [OR]
RewriteCond %{HTTP_COOKIE} newsite=true
RewriteRule ^(.*)$ new/$1 [L]
RewriteRule ^(.*)$ old/$1 [L]
Aleatório ..
# We'll use a cookie to mark a client with the backend they've been stuck to,
# so they they don't get fed /index.html from /old then /images/something.jpg
# from /new. Handle that first..
RewriteCond %{HTTP_COOKIE} sitevers=(old|new)
RewriteRule ^(.*)$ %1/$1 [L]
# They didn't have a cookie, let's give them a random backend.
# Define our mapping file, we'll set this up in a minute..
RewriteMap siteversions rnd:/var/www/map.txt
# Since we need to use the random response twice (for the directory and the
# cookie), let's evaluate the map once and store the return:
RewriteCond ${siteversions:dirs} ^(.*)$
# ..then, use what we just stored to both select the directory to use to
# respond to this request, as well as to set a cookie for subsequent requests.
RewriteRule ^(.*)$ %1/$1 [L,CO=sitevers:%1:.example.com:0]
E configure o arquivo /var/www/map.txt
com este conteúdo:
dirs new|old
Aleatório é muito mais complicado, e eu poderia ter perdido algo ... me avise se ele quebrar.