将旧的重写规则重定向到新的规则

发布于 2024-09-14 11:58:46 字数 349 浏览 3 评论 0原文

我的 .htaccess 文件中有这条规则,

RewriteRule ^business/(.*)/(.*)/(.*)$ ./businesspage.php?name=$1&place=$2&id=$3

为了 SEO 目的,我想将其缩短,因此只有两个参数,$3 & $1

但是,我希望在 google 上索引的旧网址重定向到新网址。我该怎么做?

例如 /business/name/place/id -> /id/name

谢谢

I have this rule on my .htaccess file

RewriteRule ^business/(.*)/(.*)/(.*)$ ./businesspage.php?name=$1&place=$2&id=$3

I want to make it shorter for SEO purposes, so there would be only two parameters, $3 & $1.

However, I want the old URLs indexed on google to redirect to the new ones. How do I do it?

For example /business/name/place/id -> /id/name.

Thanks

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

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

发布评论

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

评论(1

假装不在乎 2024-09-21 11:58:46

您现有的规则上面类似的内容应该适用于重定向:

RewriteRule ^business/([^/]+)/[^/]+/([^/]+)$ /$2/$1 [R=301,L]

然后我假设您还想修改现有的规则,如下所示:

RewriteRule ^([^/]+)/([^/]+)$ /businesspage.php?name=$2&id=$1

Something like this above your existing rule should work for the redirection:

RewriteRule ^business/([^/]+)/[^/]+/([^/]+)$ /$2/$1 [R=301,L]

Then I assume you also want to modify your existing rule like this:

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