.htaccess 别名 URL

发布于 2024-09-29 12:16:32 字数 468 浏览 2 评论 0原文

我正在尝试使用

Redirect Permanent /dir/subdir http://www.domain.com/other_dir/htmlfile.html

“注意”创建临时 URL 的重定向,“dir”存在于文件结构中,但“subdir”不存在。

在浏览器中,如果我输入 http://www.domain.com/dir/subdir 重定向有效(尽管“subdir”不存在)但是 http://www.domain.com/ dir/subdir/ 返回 404。

基本上我想创建一个重定向到文件的目录

I am trying to create a redirect of a temp URL using

Redirect Permanent /dir/subdir http://www.domain.com/other_dir/htmlfile.html

Note that "dir" exists in the file structure but "subdir" does not.

In the browser if I type http://www.domain.com/dir/subdir the redirect works (even though, again, "subdir" does not exist) but http://www.domain.com/dir/subdir/ returns a 404.

Basically I want to create a fake directory that redirects to a file

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

年少掌心 2024-10-06 12:16:32

这不是目录与文件的问题。你可以有任何 URL 指向任何你想要的东西,从这个意义上来说,重定向永久是相当严格的,所以如果你希望 /dir/subdir/ 也能工作,你应该声明另一个别名:
重定向永久 /dir/subdir/ http://www.domain.com/other_dir/htmlfile.html< /a>

It's not a directory vs. file thing. You may have any URL point to anything you want, Redirect Permament is pretty strict in this sense, so if you want /dir/subdir/ to work as well, you should declare another alias:
Redirect Permanent /dir/subdir/ http://www.domain.com/other_dir/htmlfile.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文