重写htaccess的老自从链接 [英] Rewrite htaccess old oscommerce links

查看:105
本文介绍了重写htaccess的老自从链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想重写所有的旧自从链接到一个新的网站。但我有麻烦,我需要重写URL的一部分。

链接看起来是这样的:

<$p$p><$c$c>http://www.domain.com/product_info.php?cPath=3_72&products_id=129&osCsid=6j3iabkldjcmgi3s1344lk1285

这改写适用于上面的链接:

 的RewriteCond%{REQUEST_URI} ^ /产品的详细信息\ .PHP $
的RewriteCond%{QUERY_STRING} ^ CPATH = 3_72和放大器; products_id = 129安培; osCsid =(A-ZA-Z0-9 -_] +)$
重写规则^(。*)$ http://www.domain.com/apple/air.html? [R = 301,L]
 

但不会为工作:

  http://www.domain.com/product_info.php?cPath=3_72&products_id=129
 

我的问题是,我想重写工作,无论在&放大器; osCsid = 6j3iabkldjcmgi3s1344lk1285 部分包括与否。

解决方案

我觉得你可以不指定结束分隔符($)实现这个

试试这个:

 的RewriteCond%{REQUEST_URI} ^ /产品的详细信息\ .PHP $
的RewriteCond%{QUERY_STRING} ^ CPATH = 3_72和放大器; products_id = 129
重写规则^(。*)$ http://www.domain.com/apple/air.html? [R = 301,L]
 

如果不把$的正则表达式匹配字符串的结尾,你基本上是说:匹配以...开头的字符串,不管是什么来后

希望这有助于:)

I am trying to rewrite all the old oscommerce links to a new website. But I am having trouble with part of the URL I need to rewrite.

The link looks like this:

http://www.domain.com/product_info.php?cPath=3_72&products_id=129&osCsid=6j3iabkldjcmgi3s1344lk1285

This rewrite works for the above link:

RewriteCond %{REQUEST_URI}  ^/product_info\.php$
RewriteCond %{QUERY_STRING} ^cPath=3_72&products_id=129&osCsid=([A-Za-z0-9-_]+)$
RewriteRule ^(.*)$ http://www.domain.com/apple/air.html? [R=301,L]

But will not work for:

http://www.domain.com/product_info.php?cPath=3_72&products_id=129

My problem is that I want the rewrite to work no matter if the &osCsid=6j3iabkldjcmgi3s1344lk1285 part is included or not.

解决方案

I think you can achieve this by not specifying the closing delimiter ($)

Give this a try:

RewriteCond %{REQUEST_URI}  ^/product_info\.php$
RewriteCond %{QUERY_STRING} ^cPath=3_72&products_id=129
RewriteRule ^(.*)$ http://www.domain.com/apple/air.html? [R=301,L]

By not putting the $ at the end of the regex string you are basically saying: match any string that starts with ..., no matter what comes after

Hope this helps :)

这篇关于重写htaccess的老自从链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆