.htaccess 重定向重写规则

发布于 2024-08-21 04:49:31 字数 476 浏览 5 评论 0原文

我已经为此奋斗了一段时间,但似乎无法使其发挥作用。我的旧系统使用了大量查询字符串来呈现页面,但它们不再是必要的。我的网址如下:

  • 旧网址:www.example.com/links.php?section=5&catid=52
  • 新网址:www.example.com/mhfs/links

名称链接是巧合的,不一定来自旧页面名称。我需要检查存在哪个部分和 catid 并将它们重定向到适当的页面。我尝试了以下操作,但这似乎没有任何作用。我做错了什么?

RewriteCond %{REQUEST_URI} ^links.php$
RewriteCond %{QUERY_STRING} ^section=5$
RewriteCond %{QUERY_STRING} ^catid=52$
RewriteRule ^(.*)$ /mhfs/links? [R=301]

任何帮助将不胜感激。

I've been fighting this for a while and can't seem to make it work. My old system used a lot of query strings to render pages but they are no longer necessary. My url is below:

  • OLD URL: www.example.com/links.php?section=5&catid=52
  • NEW URL: www.example.com/mhfs/links

The name links is coincidental and not necessarily from the old pages name. I need to check which section and catid is present and redirect them to the appropriate page from what it is. I tried the following but this just seems to do nothing. What am I doing wrong?

RewriteCond %{REQUEST_URI} ^links.php$
RewriteCond %{QUERY_STRING} ^section=5$
RewriteCond %{QUERY_STRING} ^catid=52$
RewriteRule ^(.*)$ /mhfs/links? [R=301]

Any help would be GREATLY appreciated.

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

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

发布评论

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

评论(1

泼猴你往哪里跑 2024-08-28 04:49:31

您必须打开重写引擎才能使其工作。
您可能不希望替换上的正则表达式开始符号:

RewriteEngine on

RewriteCond ...

RewriteRule ...

You must turn the rewrite engine on for it to work.
You probably don't want the regex start symbol on the replacement:

RewriteEngine on

RewriteCond ...

RewriteRule ...

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