PDA

View Full Version : DocumentRoot Equivalent



kburgoyne
03-03-2009, 07:57 PM
Greetings. On other Apache servers where I have more admin control, I'm used to using DocumentRoot to switch between versions of a web site. This would be for the primary domain. Not a subdomain.

For example, we'll have a "live" web site being served from a DocumentRoot of perhaps "public_html/version1". We'll then be beta testing the changes we're making using the directory "public_html/version2".

As soon as we're ready to switch the new version to live, we simply repoint DocumentRoot to "public_html/version2". This has the magic side effect of allowing us to quickly switch back to "public_html/version1" should something unexpected happen.

The use of DoucmentRoot to select the web site version is very much like being able to flip a switch and immediately change (in entirety) the web site that's being accessed.

Any way to accomplish the equivalent (for the primary domain) using BlueHost?

Thanks!

wysiwyg
03-03-2009, 10:02 PM
Something like this in your htaccess file..

RewriteEngine On
RewriteRule ^$ /version1/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /version1/$1 [L]

kburgoyne
03-04-2009, 03:50 PM
Thanks, wysiwyg. You've pointed me in a great direction in which to educate myself. Playing around with a local Apache test server, your recommendation seemed to be working.

It occurred to me that another approach to what I want to do is simply renaming folders to and from "public_html". I just tried that to check whether "public_html" is locked when Apache is running. It appears that it isn't and it will rename.

I think the renaming of public_html is a little better approach since it keeps Apache's URL handling activities more straight-forward. However I still want to thank you for expanding my education of Apache configuration options.

wysiwyg
03-05-2009, 09:53 AM
Yeah, you could do it that way. It would use less processing.

The only thing about that is it won't be instant, there will be a delay between when you rename the first public_html folder and the replacement.

felgall
03-05-2009, 11:45 AM
Also doing it that way means that if you add any add-on domains that you will also need to copy them from the old public_html to the new and they will be affected by the change as well whereas if you move the main domain so it is in a folder like the add-on domains than you can do the replaces without affecting anything else and have it happen instantly rather than the delay with everything offline while you rename.