重定向已经重定向的页面

发布于 2024-09-30 19:29:21 字数 624 浏览 1 评论 0原文

RewriteRule ^teamstore/(.*)/$ /teamproduct.php?teamproduct=$1&products=true [NC,L]
RewriteRule ^teamstore-(.*)/$ /teamproduct.php?teamproduct=$1&products=true [NC,L]

情况是这样的。我们已经重写了这些网址,但我们想要更改这些页面的格式,以便它们由连字符而不是斜杠分隔。

我尝试了重定向匹配,但这在网址末尾添加了额外的 php 值参数。结果是:

RedirectMatch 301 /teamstore/(.*) http://www.domainname.com/teamstore-$1/

结果是...

teamstore-valuehere//?teamproduct=2352323&productes=true

我希望输入原始地址 teamstore/info/ 的人能够定向到 teamstore-info/ - 关于如何实现此目的有什么想法吗?

主要原因是为了避免 Google 搜索结果中现有链接的重复内容问题。

RewriteRule ^teamstore/(.*)/$ /teamproduct.php?teamproduct=$1&products=true [NC,L]
RewriteRule ^teamstore-(.*)/$ /teamproduct.php?teamproduct=$1&products=true [NC,L]

Here's the situation. We've already had theese urls rewritten, but we want to change the formatting of these pages so they're separated by hyphen instead of a slash.

I tried redirectmatch but this added additional php value parameters to the end of the urls. It came out to be

RedirectMatch 301 /teamstore/(.*) http://www.domainname.com/teamstore-$1/

Here was the result...

teamstore-valuehere//?teamproduct=2352323&productes=true

I want someone who types in the original address teamstore/info/ to get directed to teamstore-info/ - Any ideas on how to accomplish this?

The main reason is to avoid duplicate content issues with existing links in Google Search Results.

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

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

发布评论

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

评论(1

一人独醉 2024-10-07 19:29:22

规则的顺序可能很重要,但如果您出于 SEO 原因想要 301 重定向初始请求,那么我会将您的 RewiteRules 更改为以下内容。

RewriteRule ^teamstore/(.*)/$ teamstore-$1/ [R=301,L]
RewriteRule ^teamstore-(.*)/$ /teamproduct.php?teamproduct=$1&products=true [NC,L]

这将首先将 teamstore/info/ 转换为 teamstore-info/ 并发送适当的 301 响应。第二遍时,它将重定向到您想要的 php。

请注意,就性能而言,这并不理想。然而,它确实实现了让谷歌高兴的目标。

Order of the rules can matter, but if you want to 301 redirect the initial request for SEO reasons, then I would change your RewiteRules to the following.

RewriteRule ^teamstore/(.*)/$ teamstore-$1/ [R=301,L]
RewriteRule ^teamstore-(.*)/$ /teamproduct.php?teamproduct=$1&products=true [NC,L]

This will first translate teamstore/info/ to teamstore-info/ and send the appropriate 301 response. Upon second pass it will redirect to the php you want.

Note, this is not ideal as far as performance. Yet, it does accomplish the goal of making Google happy.

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