Reputation: 1514
I've read many posts on this subject, but for some reason none of code seems to work.
If I have a domain example.com
, I would like to redirect it to example.com/folder
without the user knowing about the redirection.
# file: public_html/.htaccess
RewriteEngine On
RewriteRule ^/(.*)$ /folder/$1 [L]
But it doesn't send me to folder
. Could someone tell me what I'm doing wrong.
Thanks
Upvotes: 1
Views: 43
Reputation: 785128
Remove leading slash and include a negative lookahead:
RewriteEngine On
RewriteCond %{THE_REQUEST} \s/+folder/ [NC]
RewriteRule ^ - [R=404,L]
RewriteRule ^((?!folder/).*)$ /folder/$1 [L,NC]
Upvotes: 1