简体   繁体   English

使用重写规则.htaccess进行重定向的问题

[英]Issues with redirecting using rewrite rule .htaccess

I've searched the forums, but I'm stuck. 我已经搜索了论坛,但被卡住了。

I am switching from Miva to Opencart and going from dynamic urls to seo friendly. 我正在从Miva切换到Opencart,并从动态网址转到seo友好。

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. 它将我所有的旧google链接发送到我的目录首页。 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? Miva中的旧产品代码现在是Opencart中的型号,那么我在最后一条路径中到底想调用什么代码呢? I want it to look like the search results page in Opencart: 我希望它看起来像Opencart中的搜索结果页面:

www.domain-name.com/catalog/786005

Someone must be able to see what I'm missing here!! 一定可以看到我在这里想念的东西!

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. 您需要做的是使用捕获的%1 ,使用在重写器中的条件中使用的查询字符串的反向引用。 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. 让我知道如何为您解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM