htaccess 跳过文件夹
我到处都看到 htaccess 问题,但我似乎无法让它做我想做的事。我不确定我是否需要重定向或重写。
我正在寻找一种使用子文件夹但使其看起来没有子文件夹的方法。
我的域根目录中有一堆文件夹:
www.mysite.com/folder1
www.mysite.com/folder2
www.mysite.com/folder3
www.mysite.com/folder4
我希望能够将文件夹 1 和文件夹 2 移动到子文件夹,但用户不可以看到该文件夹。例如
www.mysite.com/x/folder1
www.mysite.com/x/folder2
www.mysite.com/folder3
www.mysite.com/folder4
,但是用户仍然会看到它原来的样子。
看来我必须使用重定向和重写。如果用户访问 www.mysite.com/folder1
,实际上将位于 www.mysite.com/x/folder1
中,而不知道自己位于该子文件夹中。
当然,我需要在不破坏文件夹 4 和文件夹 5 的情况下执行此操作。有想法吗?尖端?技巧?我对 htaccess 不太熟悉
I see htaccess questions all over the place but I cant seem to get the thing to do what I want. Im not sure if a redirect or a rewrite is what I need.
Im looking for a way to use a sub folder but make it look there is not a subfolder.
I have a bunch of folders in the root of my domain:
www.mysite.com/folder1
www.mysite.com/folder2
www.mysite.com/folder3
www.mysite.com/folder4
Id like to be able to move folder1 and folder2 to a subfolder but not have that folder visible to the user. For example
www.mysite.com/x/folder1
www.mysite.com/x/folder2
www.mysite.com/folder3
www.mysite.com/folder4
But the user would still see it as it originally was.
It seems like I would have to use a redirect and a rewrite. If a user goes to www.mysite.com/folder1
the will actually be in www.mysite.com/x/folder1
without knowing that they are in that subfolder.
Of course I need to do this without disrupting folder4 and folder5. Ideas? Tips? Tricks? Im not too familiar with htaccess
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这对我有用,也许对其他人有帮助:
这告诉服务器忽略公共文件夹,因此当我的 URL 实际上是 mysite.com/public/file 时,它会显示并响应 mysite.com/file
This is what worked for me, maybe it will help someone else:
This is telling the server to ignore the Public folder, so when my URL is actually mysite.com/public/file it shows and responds to mysite.com/file