Take the 2-minute tour ×
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 (.*) http://www.example.com/$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 www.myurl.com/subdirectory how can I hide subdirectory from URL? –  Andrew Oct 23 '12 at 1:05
    
Check this answer out stackoverflow.com/a/10427485/804087 –  Anagio Oct 23 '12 at 10:45

Your Answer

 
discard

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.