Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

How to redirect requests to another folder using .htaccess?

I have my root directory and my website looks into that directory. I want it to look in the /subdirectory/ instead. I can't modify the server config.

share|improve this question
What have you tried? – John Conde Oct 16 '12 at 17:13

1 Answer 1

Try this:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule (.*)$1 [R=301,L]
RewriteRule ^$ subdirectory [L]

If you want an external redirect, set the R flag there as well:

RewriteRule ^$ /subdirectory [L,R=301]
share|improve this answer
OK, it redirects, but I see how can I hide subdirectory from URL? – Andrew Oct 23 '12 at 1:05
Check this answer out – Anagio Oct 23 '12 at 10:45

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.