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

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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.