.htaccess - Seo 301 绝对 URL 重定向,Prestashop

标签 .htaccess url redirect seo prestashop

我正在清理一些旧东西,我需要做一些 301 重定向。

例如:

我试过 htaccess:

RedirectMatch 301 /product.asp?product=371&sub=0&page=1 /category/test

但上面的代码不起作用,它显示 404 页面并忽略我刚刚进行的重定向。请注意,product.asp 不作为文件存在!

但是如果我使用:

RedirectMatch 301 /product.asp /category/test/

它工作正常,但现在我无法根据特定文件的查询字符串进行重定向。

有什么建议吗?顺便说一句,我正在使用 Prestashop=) 最好的,西蒙

最佳答案

您不能使用 RedirectMatch 指令匹配查询字符串。使用 mod_rewrite 规则代替:

RewriteEngine On

RewriteCond %{QUERY_STRING} product=371&sub=0&page=1
RewriteRule ^product\.asp$ /category/test/? [L,NC,R=301]
目标中的

? 是剥离现有的查询字符串。

关于.htaccess - Seo 301 绝对 URL 重定向,Prestashop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33151571/

相关文章:

php - 请求 .php 时 css 不工作,如 "/example.php/"但显示内容

.htaccess - htaccess-301使用分析广告系列参数重定向

url - 匹配模式 Google URL

node.js - 是否可以为多个本地主机项目设置自定义开发域?

apache - 使用 htaccess 进行多域重定向

google-chrome - Chrome 在 HTTP 302 重定向时取消 CORS XHR

php - https ://to Http rewrite in . htaccess

apache - 尝试修复时出错

php - 当 URL 中包含 “” 时,为什么通过 URL 从 MySQL 获取数据不起作用?

javascript - 选择下拉菜单后重定向到 URL