2

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.

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]
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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