.htaccess 重写以将根 URL 重定向到子目录
问题描述:
试图得到
www.example.com
直接去
www.example.com/store
我尝试了多位代码,但没有任何效果.
I have tried multiple bits of code and none work.
我尝试过的:
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]
我做错了什么?
答
您可以使用重写规则,该规则使用 ^$ 表示根并将其重写到您的/store 目录,如下所示:
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]