重写单个 url 帮助

发布于 2024-08-24 15:14:30 字数 260 浏览 3 评论 0原文

我正在尝试将以下 url: 重写

index.php?route=checkout/cart

/cart

using:

RewriteRule ^index.php?route=checkout/cart$ /basket [L] 

但它似乎不起作用。有人知道我做错了什么吗?

谢谢

I'm trying to rewrite the following url:

index.php?route=checkout/cart

to

/cart

using:

RewriteRule ^index.php?route=checkout/cart$ /basket [L] 

However it doesn't seem to work. Anyone know what I'm doing wrong?

Thanks

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

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

发布评论

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

评论(2

走野 2024-08-31 15:14:30

RewriteRule 仅测试URL 路径。您需要 RewriteCond 进行测试查询:

RewriteCond %{QUERY_STRING} ^route=checkout/cart$
RewriteRule ^index\.php$ /basket [L,R=301]

附加的 R=301 标志将导致状态代码为 301(永久重定向)的外部重定向,而不是内部重定向。

如果你想反过来:

RewriteRule ^basket$ index.php?route=checkout/cart [L]

RewriteRule does only test the URL path. You need RewriteCond to test the query:

RewriteCond %{QUERY_STRING} ^route=checkout/cart$
RewriteRule ^index\.php$ /basket [L,R=301]

The additional R=301 flag will cause an external redirect with the status code 301 (permanent redirect) instead of an internal redirect.

And if you want the other way round:

RewriteRule ^basket$ index.php?route=checkout/cart [L]
一杆小烟枪 2024-08-31 15:14:30

您需要发送重定向,以便新 URL 反映在浏览器地址栏中。因此,将 R 添加到 [L] 中。

RewriteRule ^index.php?route=checkout/cart$ /basket [R,L] 

如果您希望搜索机器人忽略“丑陋”的 URL 和/或将其从索引中删除并使用新的,则发送 301 重定向。

RewriteRule ^index.php?route=checkout/cart$ /basket [R=301,L] 

You need to send a redirect so that the new URL get reflected in browser address bar. So, add R to the [L].

RewriteRule ^index.php?route=checkout/cart$ /basket [R,L] 

If you'd like that searchbots should ignore the "ugly" URL and/or remove it from the indexes and use the new instead, then send a 301 redirect.

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