的.htaccess重写重定向根URL子目录子目录、重写、重定向、htaccess

2023-09-02 00:18:01 作者:與可愛私奔

试图让

www.example.com

要直接去

www.example.com/store

我已经试过了code和没有工作的多个位。请帮帮忙!

I have tried multiple bits of code and none work. Please help!

我已经试过什么:

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?

推荐答案

您可以使用使用重写规则的 ^ $ 以重新present的根源,重写你的/存储目录,像这样的:

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]