[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-users] Previewing domains



The problem of viewing virtual sites that don't yet have dns propogated
seems to come up occasionally, and i've run into it a few times also, so i
finally decided to figure out a way to do it , preferably without creating
whopping security holes.....

so here's a fairly clean solution, no config file changes, no weird
symlinks.....just a .htaccess file...

Will let you access a virtual site indirectly from another (working) site
ie you can look at www.new.com using a URL like
http://www.isp.com/Preview/www.new.com/

first: make a directory named Preview , in it, make a .htaccess file
put this in it:

RewriteEngine on
RewriteBase /Preview
RewriteRule ^www\.([^/]+)$  /Preview/www.$1/ [L,R]
RewriteRule ^www\.([^/]+)(/(.*))? http://www.$1/$3 [P]


That's it.....

notes: web sites with absolute paths in image/links will screw up, but
that's a problem with user web sites also, and generally a bad idea,
some CGI's won't like this either, but for just looking at pages it should
be fine....

Assumption: all your sites start with www.  ok, you can change this, it
just makes it a bit more paranoid ;0

the 2 rewrite rules above are fairly straightforward, the first just adds
a trailing slash (necessary or the browser will screw up directory
references)

the second is sneakier, it rewrites the url, and then makes it into a
proxy request, since the server sees this like it was a nornal request 
at that point it does the necessary authentication/option checks in the
same fashion it would if it were just a plain request, much cleaner than
trying to map across directorys to a different site that might not be
intended to have the same access as the initial site.....

Apache in the Raq2 has mod_proxy compiled in , don't know about the 3 or
3i tho....(anyone check?)

gsh

use at your own risk, not supported by cobalt, you break it you own it etc