Carter Roeser Carter Roeser - 1 year ago 230
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?


Answer Source
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download