使用重写规则.htaccess重定向的问题(Issues with redirecting using rewrite rule .htaccess)

编程入门 行业动态 更新时间:2024-10-26 06:28:16
使用重写规则.htaccess重定向的问题(Issues with redirecting using rewrite rule .htaccess)

我搜索了论坛,但我被困住了。

我正在从Miva切换到Opencart,从动态网址转向seo友好。

我现在有这个:

RewriteCond %{QUERY_STRING} ^Screen=PROD&Store_Code=SI&Product_Code(.*)$ RewriteRule ^(.*)$ http://www.domain-name.com/catalog/ [R=301,L] RewriteCond %{QUERY_STRING} ^Screen=PROD&Product_Code=(.*)$ RewriteRule ^(.*)$ http://www.domain-name/catalog/ [R=301,L]

它将我所有旧的谷歌链接发送到我的目录首页。 这是我猜的第一步。

Miva中的旧产品代码现在是Opencart中的型号,那么我在最后一条路径中调出模型代码又是什么呢? 我希望它看起来像Opencart中的搜索结果页面:

www.domain-name.com/catalog/786005

有人必须能够看到我在这里失踪的东西!!

I've searched the forums, but I'm stuck.

I am switching from Miva to Opencart and going from dynamic urls to seo friendly.

I have this right now:

RewriteCond %{QUERY_STRING} ^Screen=PROD&Store_Code=SI&Product_Code(.*)$ RewriteRule ^(.*)$ http://www.domain-name.com/catalog/ [R=301,L] RewriteCond %{QUERY_STRING} ^Screen=PROD&Product_Code=(.*)$ RewriteRule ^(.*)$ http://www.domain-name/catalog/ [R=301,L]

It sends all my old google links to my catalog front page. It's a first step I guess.

The old product codes in Miva are now the Model numbers in Opencart so what the heck do I put in that last path to call out the model code? I want it to look like the search results page in Opencart:

www.domain-name.com/catalog/786005

Someone must be able to see what I'm missing here!!

最满意答案

您需要做的是使用您在重写条件中使用的查询字符串中的反向引用,使用您捕获的%1 。 你很亲密 您还可以将其合并为一条规则。

RewriteEngine On RewriteCond %{QUERY_STRING} Product_Code=(.*) RewriteRule ^(.*)$ http://www.domain-name.com/catalog/%1? [R=301,L]

让我知道这对你有什么影响。

What you need to do is use the backreference from the query string that you used in the condition in the rewriterule using the %1 that you captured. You were close. You can also consolidate it down to one rule.

RewriteEngine On RewriteCond %{QUERY_STRING} Product_Code=(.*) RewriteRule ^(.*)$ http://www.domain-name.com/catalog/%1? [R=301,L]

Let me know how that works out for you.

更多推荐

本文发布于:2023-08-07 18:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465509.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重写   重定向   规则   htaccess   rule

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!