.htaccess rewrite to redirect root URL to subdirectory

.htaccessmod-rewriteredirect

Trying to get

www.example.com

to go directly to

www.example.com/store

I have tried multiple bits of code and none work.

What I've tried:

Options +FollowSymlinks
RewriteEngine on

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

RewriteCond %{HTTP_HOST} ^(.+)\www.example\.com$
RewriteRule ^/(.*)$ /samle/%1/$1 [L]

What am I doing wrong?

Best Answer

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]
Related Topic