论坛个人资料链接的 htaccess 301 重定向规则

发布于 2024-12-25 20:13:04 字数 378 浏览 1 评论 0原文

我切换了论坛平台,并且想使用 301 重定向将请求重定向到会员个人资料。

用户配置文件的旧平台路径是:www.example.com/forum/member.php?u=XXXXXX 用户配置文件的新平台路径为: www.example.com/user/XXXXXX

切换期间用户 ID 保持不变。

我尝试通过编写以下 RewriteRule 来实现此目的:

RewriteRule ^forum/member.php?u=(.*)$ http://www.example.com/user/$1 [R=301,L]

不幸的是,由于某种原因它不起作用,我不明白为什么。任何帮助将不胜感激!

谢谢, -克里斯

I switched forum platforms and I'd like to redirect requests to member profiles using a 301 redirect.

The old platform path to user profiles was: www.example.com/forum/member.php?u=XXXXXX
The new platform path to user profiles is: www.example.com/user/XXXXXX

The user IDs have remained the same during the switch.

I tried to accomplish this by writing the following RewriteRule:

RewriteRule ^forum/member.php?u=(.*)$ http://www.example.com/user/$1 [R=301,L]

Unfortunately, it's not working for some reason and I can't figure out why. Any help would be greatly appreciated!

Thanks,
-Chris

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

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

发布评论

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

评论(1

你爱我像她 2025-01-01 20:13:04

您无法从 RewriteRule 指令访问查询字符串。

请尝试以下方法。

#if the query string has a u parameter
RewriteCond %{QUERY_STRING} (^|&)u=([^&]+) [NC}
RewriteRule ^forum/member.php$ http://www.example.com/user/%2 [R=301,L]

You cannot access the query string from a RewriteRule directive.

Try the following instead.

#if the query string has a u parameter
RewriteCond %{QUERY_STRING} (^|&)u=([^&]+) [NC}
RewriteRule ^forum/member.php$ http://www.example.com/user/%2 [R=301,L]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文