Posted by Steve on Thu 6 Mar 2008 at 00:15
This should be a simple problem to solve, but I've yet to find a good solution, so any assistance would be most welcome. If you'd like to redirect to another website if a directory root has no files in it, how would you do so?
Assume that you have an Apache virtual host which has a directory root with no files within it. In that case it would be nice to redirect to a new location with a message such as "there are no files here yet".
The naive approach would be to have something like this:
# Excluding existing files and folders
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
# and if there is nothing in the root redirect
RewriteRule ^/$ http://www.steve.org.uk/
Unfortunately this does not work, and I'm out of ideas..
This article can be found online at the Debian Administration website at the following bookmarkable URL:
This article is copyright 2008 Steve - please ask for permission to republish or translate.