htaccess删除部分URL路径并停留在基本位置(在localhost) [英] htaccess removing part of url path and stay at base (at localhost)

查看:103
本文介绍了htaccess删除部分URL路径并停留在基本位置(在localhost)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在这里进行了所有质量检查,但是我做错了。

I've gone through all QA here, but I am not getting it right.

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

I am using wamp and my site resides in a folder named '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/

如果我在规则中明确提及它,那么它将起作用。

If I explicitly mention it in rule then it works.

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

可以我写的规则没有明确添加/ site /?

Can I write a rule without explicitly adding /site/ ?

推荐答案

您可以尝试吗?

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

这篇关于htaccess删除部分URL路径并停留在基本位置(在localhost)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆