使用 .htaccess 重定向子目录并清理 URL
所以,这是一个有点奇怪的情况。我正在网站的子文件夹中为我的同事托管一个开发服务器。基本上文件结构如下所示:
public_html/my_subfolder/public/index.php
因此,我试图做的是,如果用户输入“www.mysite.com/my_subfolder”,他们将被带到“public /index.php”页面,URL 中没有出现公共子文件夹。考虑到它只是一个开发服务器,我仍然在搞乱它,这有点愚蠢。
我正处于这个问题上,我已经搞砸了这么久了,我真的想让它现在就开始工作,这样,如果没有别的事情,我就能学到一些东西。任何帮助将不胜感激!
So, this is somewhat of a strange situation. I'm hosting a development server for a person I'm working with in a subfolder of my website. Basically the file structure looks like this:
public_html/my_subfolder/public/index.php
So what I'm attempting to do is make it so that if a user types "www.mysite.com/my_subfolder" they are taken to the "public/index.php" page without the public subfolder appearing in the URL. It's kind of silly that I'm still messing with this, considering it's only a development server.
I'm just at the point where I've messed with it for so long I really want to get it to work now, so that, if nothing else, I'll learn something. Any help would be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的 .htaccess 文件中尝试此规则:
这将重定向所有内容,因此请确保也从
my_subfolder/public
提供静态文件,如 js、css、图像等。Try this rule in your .htaccess file:
This will redirect everything so make sure to serve your static files like js, css, images etc from
my_subfolder/public
as well.尝试使用 P 标志
谢谢
S
try using the P flag
Thanks
S