.htaccess rewrite to redirect root URL to subdirectory

Solution 1:

You can use a rewrite rule that uses ^$ to represent the root and rewrite that to your /store directory, like this:

RewriteEngine On
RewriteRule ^$ /store [L]

Solution 2:

I was surprised that nobody mentioned this:

RedirectMatch ^/$ /store/

Basically, it redirects the root and only the root URL. The answer originated from this link

Solution 3:

Try this:

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

If you want an external redirect (which cause the visiting browser to show the redirected URL), set the R flag there as well:

RewriteRule ^$ /store [L,R=301]