如何从一个子目录重定向到另一个目录,但使用 mod_rewrite 从 URI 中删除原始子目录

发布于 2024-08-26 22:49:33 字数 318 浏览 5 评论 0原文

我有一个在 12001 上运行的 Ruby on Rails 应用程序。我当前正在使用一些 ReWriteCond 检测将子域重定向到 127.0.0.1:12001。 现在我想将我的子目录重定向到该 Rails 应用程序。

http[s]://domain.com/redmine

当前

127.0.0.1:12001

规则将 REQUEST_URI 应用于上述 Rails 路径,但我需要从 REQUEST_URI 前面删除“/redmine”...

有什么想法吗?

I have a Ruby on Rails app running on 12001. I am currently redirecting a subdomain to 127.0.0.1:12001 using some ReWriteCond detection.
Now I want to redirect my subdirectory to that rails app.

http[s]://domain.com/redmine

to

127.0.0.1:12001

The current rules apply REQUEST_URI to the above rails path, but I need to strip "/redmine" from the front of REQUEST_URI...

Any ideas?

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

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

发布评论

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

评论(2

爱你是孤单的心事 2024-09-02 22:49:33

您可以在不使用 mod_rewrite 的情况下执行此操作。

Redirect Permanent /redmine http://127.0.0.1:12001

这应该做你想做的。

You can do this without mod_rewrite.

Redirect Permanent /redmine http://127.0.0.1:12001

This should do what you want.

何以心动 2024-09-02 22:49:33
RewriteRule ^/redmine/(.*)$ http://127.0.0.1:12001/$1 [QSA,L]

如果规则放置在 Directory 指令中,则:

RewriteRule ^redmine/(.*)$ http://127.0.0.1:12001/$1 [QSA,L]

末尾的参数:

  • [QSA] 附加查询字符串(由您决定);
  • [L] 使其成为最后一条规则

NB /redmine 将不会与此规则匹配,但我将放弃您尝试过的内容,仅使用子路径,例如 /redmine/abc

RewriteRule ^/redmine/(.*)$ http://127.0.0.1:12001/$1 [QSA,L]

If the rule is placed in the Directory directive, then:

RewriteRule ^redmine/(.*)$ http://127.0.0.1:12001/$1 [QSA,L]

The parameters at the end:

  • [QSA] appends the query string (up to you);
  • [L] makes it the last rule

NB /redmine will not be matched by this rule, but I am going off what you tried, only subpaths, e.g. /redmine/abc

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