mod_rewrite 新手需要帮助(简单?)重写规则

发布于 2024-09-15 04:48:12 字数 624 浏览 1 评论 0原文

我试过。我失败了。这就是我想要做的:

使用 firebug,我看到样式表和其他内容的请求标头中的 GET 字符串被应用程序修改(我无法修改)。我认为一个简单的重写规则可能会有所帮助,但我无法让它发挥作用。这是我需要的:


输入:/content/2010/08/forum/styles/xyz/theme/normal.css

输出:/forum/styles/xyz/theme/normal.css< /strong>


输入:/content/forum/styles/xyz/template/blah.js

输出 /forum/styles/xyz/template/blah.js


输入: >/content/my-own-page/forum/happy.htm

输出:/forum/happy.htm


因此,无论出现什么,如果它包含“forum/”,那么就去掉“forum/”之前的内容并返回“forum/”中的所有内容。

I tried. I failed. Here's what I want to do:

Using firebug I saw that the GET string in the request header for my stylesheets and other content was being munged by the application (which I can't modify). I think a simple rewrite rule might help but I can't get it to work. Here's what I need:


input: /content/2010/08/forum/styles/xyz/theme/normal.css

output: /forum/styles/xyz/theme/normal.css


input: /content/forum/styles/xyz/template/blah.js

output /forum/styles/xyz/template/blah.js


input: /content/my-own-page/forum/happy.htm

output: /forum/happy.htm


So, whatever comes in IF it contains "forum/" then get rid of what precedes "forum/" and return everything from "forum/", foward.

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

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

发布评论

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

评论(1

陈独秀 2024-09-22 04:48:12

沿着这些思路的东西可能可以完成这项工作。

RewriteRule ^.*/forum/(.*)$ /forum/$1

Something along these lines should probably do the job.

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