Forum Moderators: phranque
www.newsite.com
and our coresponding test site
www.ourtestserver.com/sites/newsite.com
on the test server that same image example would resolve to "www.ourtestserver.com/images/picture.jpg" and not "www.ourtestserver.com/sites/newsite.com/images/picture.jpg"
any ideas of the best way to accomplish this. preferably an .htaccess file we could plop in each sites directory?
Thanks
I assume that you stop all search engines from accessing the test site. That would be a quite vital step to take. I mostly use password protection rather than rely on robots tags or files.
Somehow the .htaccess file would need to know which "site" to rewrite or redirect back to for images only. You could use the referrer data for that I suspect. You would only need one file to work for all of your test sites.
I am not sure whether it is best coded as a redirect or as a rewrite. If search engines aren't involved then it may not matter.
.
This is guesswork, and might get you started:
RewriteCond %{HTTP_REFERER} http://www\.ourtestserver\.com/sites/([^\?])\?
RewriteRule ^images/([^.]+\.(jpeg?¦png¦gif)) /sites/%1/images/$1 [L] I assume there is no site in the root of the test domain. If there is, then you will need to add exclusions for that, otherwise images for that site may well fail to display.
.
I tackle this in the site scripting. There's a variable in the first PHP include that defines "path to images", among other things.
Sometimes I automate it in PHP, by testing the domain name a nd setting the path depending on whether the test server or live server is detected.
[edited by: g1smd at 2:43 pm (utc) on Sep. 24, 2008]
Referrer-based rewrites are problematic, in that many plug-ins and media players will not send a referrer header, and this can lead to unexpected failures of referrer-based logic (and rewrites). If you choose to use the mod_rewrite-based approach, then I'd suggest using the HTTP_HOST variable as the basis for rewriting, instead of HTTP_REFERER.
Jim
the more i thought about it, the more i figured a virtual host was the right answer. but i'm not quite sure how to configure that right.
to complicate things our test server url is like "admin.realserver.com" admin being a subdomain pointed to the test server's IP. so in the end i'd end up having a url like:
[newsite.com.admin.realserver.com...] ?
doesn't that mean i'd have to set up A records on the realserver?
or i was also thinking set up [newsite.com.255.255.255.255...] but there are two websites set up at this IP and the default destination is not the one i want to be using.