-1

我不需要为我所有的旧产品 url 编写一个简单的重定向,而是需要一个重写规则来重定向几个具有非常相似 url 的链接,这些链接仅由一个用句点分隔的数字不同。下面的几个链接示例将全部重定向到一个 url。此外,“a131.1.html”中的字符大小写也应被忽略,而 i 仅用于文件名部分的目标 url。

site.com/product/cat/a131.1.html
site.com/product/cat/a131.2.html
site.com/product/cat/a131.3.html
site.com/product/cat/a131.4.html
...
site.com/product/cat/a131.30.html

to

new-site.com/101
4

2 回答 2

0

类似的东西(因为我不清楚应该变成什么):

RewriteEngine On

RewriteRule ^product/cat/a([0-9]+)\.([0-9]+)\.html$ http://new-site.com/$1-$2 [L]

(我还没有尝试过,但希望它会起作用。在最坏的情况下,你现在知道要遵循的路线,你应该寻找什么)

于 2013-05-18T00:36:18.637 回答
0

你可以缩小你的 .htaccess 一点。

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^(www\.)?oldsite\.com$
RewriteRule ^product/cat/a131\.\d+\.html$ http://newsite.com/b321 [R=301,L]
于 2013-05-20T04:30:37.277 回答