Aaron
Aaron

Reputation: 1

.htaccess conditional redirect question

I'd like to use .htaccess to redirect if there is a particular subdirectory present.

Basically, I'd like to redirect http://www.mydomain.com to http://www.mydomain.com/install if the install subdirectory exists.

I know I need to do it with a RewriteCond. So far, this is all I have.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -d

I'm not sure what else to do to make this work. Really need help understanding how .htaccess works.

I'd also like to combine it with rewriting to www.

Please help?

Upvotes: 0

Views: 382

Answers (1)

Jake
Jake

Reputation: 2470

This should work, update the path to your install folder in the RewriteCond:

RewriteCond /var/www/domain/htdocs/install -d
RewriteRule .* install/ [L]

Upvotes: 1

Related Questions