无法使用 Apache RewriteRule

发布于 2024-12-28 02:29:36 字数 271 浏览 2 评论 0原文

我想使用 Apache RewriteRule 将 URL 目标页面更改为 abc.php。我已将 RewriteEngine 设置为 On 但我发现了这个问题。

我使用的正则表达式:

RewriteRule ^viewthread\.php.tid=12345$ abc.php

要匹配的URL字符串:

viewthread.php?tid=12345

为什么没有成功匹配?

I would like to use Apache RewriteRule to change the URL target page to abc.php. I have set RewriteEngine On but I found this problem.

Regexp I used:

RewriteRule ^viewthread\.php.tid=12345$ abc.php

The URL string to match:

viewthread.php?tid=12345

Why it is not successfully matched?

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

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

发布评论

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

评论(3

药祭#氼 2025-01-04 02:29:36

使用查询字符串重写 URL 比重写普通 URL 稍微复杂一些。您必须编写如下内容:

RewriteCond %{REQUEST_URI}  ^/viewthread\.php$
RewriteCond %{QUERY_STRING} ^tid=12345$
RewriteRule ^(.*)$ http://mydomain.site/abc.php [R=302,L]

请参阅这些文章以获取更多帮助:

Rewriting URLs with query strings is slightly more complicated than rewriting plain URLs. You'll have to write something like this:

RewriteCond %{REQUEST_URI}  ^/viewthread\.php$
RewriteCond %{QUERY_STRING} ^tid=12345$
RewriteRule ^(.*)$ http://mydomain.site/abc.php [R=302,L]

See those articles for more help:

栀子花开つ 2025-01-04 02:29:36

我想是因为你错过了?在规则...

RewriteRule ^viewthread.php?tid=12345$ abc.php

i think because you have missed the ? in the rule...

RewriteRule ^viewthread.php?tid=12345$ abc.php
娇纵 2025-01-04 02:29:36

不应该是:

RewriteRule ^/viewthread\.php\?tid=12345$ /abc.php

Shouldn't it be:

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