Carter Roeser Carter Roeser - 13 days ago 7
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?

Thanks!

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

Comments