重定向所有链接以在主 url 前面包含一个段
我使用 mamp 设置了一个本地网站,我在同一 mamp 安装上运行了其他网站,并且我使用我网站上的链接,例如 About
它会将用户定向到 http://localhost/about,但我需要它定向到 http://localhost/chuck/host
chuck 是该站点所在的文件夹,文件路径:/Applications/MAMP/ htdocs/chuck
htaccess 文件中是否有一种方法可以通过将 /chuck 插入 url 的前面来自动重定向任何链接?
我希望这是可能的,所以我不必遍历每个文件并将 /chuck 放在(对于本示例)/about 前面,以使其 http://localhost/chuck/about
I setup a local website using mamp, there are other sites I run in development on the same mamp install and I use links on my site like <a href="/about">About</a>
It will direct the user to http://localhost/about, but I need it to direct to http://localhost/chuck/host
chuck is the folder that this site is within, file path: /Applications/MAMP/htdocs/chuck
Is there a way in the htaccess file that any link automatically is redirected with /chuck plugged into the front of the url?
I hope this is possible, so I do not have to go thru every file and put /chuck in front of (for this example), /about, to make it http://localhost/chuck/about
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
基本上,
%{http_host}
之后的任何内容都将放在/chuck
之后。这将重定向所有内容,使其前面有/chuck
。这必须放在
/path/to/htdocs
文件夹中。但是,这也会导致您无法访问您在那里托管的任何其他网站。Basically, anything after the
%{http_host}
will be put after/chuck
. This will redirect EVERYTHING to have/chuck
in front of it.This will have to be put in the
/path/to/htdocs
folder. However, it will also make it impossible to visit any other site you may have hosted there.