Carter Roeser Carter Roeser - 6 months ago 70
Apache Configuration Question

.htaccess If file exists, set document root to subdirectory

I would like to use .htaccess to set a rule where if config.php exists then set root directory to / and if config.php does not exist, set root directory to /install.

How can this be done?


RewriteEngine on
RewriteCond %{DOCUMENT_ROOT}/config.php !-f
RewriteRule ^/?$ /install [L]

This will set /install as your home dir if /config.php does not exist in your filesystem.