htaccess删除了url路径的一部分,并停留在基本位置(localhost)


htaccess removing part of url path and stay at base (at localhost)

我已经完成了这里的所有QA,但我没有做好。

我正在使用wamp,我的网站位于名为"site"的文件夹中。

我正在尝试重定向此

http://localhost/site/public/foo/bar/

http://localhost/site/foo/bar/

使用以下规则:

RewriteEngine On
RewriteBase /site/
RewriteRule ^public/(.*)$ /$1 [L,R=301,QSA]

但它重定向到

http://localhost/foo/bar/

若我在规则中明确提到它,那个么它就起作用了。

RewriteRule ^public/(.*)$ /site/$1 [L,R=301,QSA]

我可以在不显式添加/site/的情况下编写规则吗?

你能试试这个吗?

RewriteRule ^public/(.*)$ $1 [L,R=301,QSA]