0

我想将带有连衣裙的网址重定向到apparel-clothes/dresses. 例如:

  • abc.com/dresses
  • abc.com/dresses/casual
  • abc.com/dresses/evening-wear
  • abc.com/dresses/little-black-dress

应该全部重定向到abc.com/apparel-clothes/dresses. 我试图编写重定向规则,但它不起作用:

RewriteRule ^(.*)/dresses/(.*)$ $1/apparel-clothes/dresses/$2 [R=301,L]
4

2 回答 2

0

你很接近,但前导斜杠不匹配.htaccessin RewriteRule

使用此规则:

RewriteEngine On

RewriteRule ^(dresses.*)$ /apparel-clothes/$1 [L,NC,R=301]
于 2013-10-17T11:30:39.557 回答
0

The domain name is never part of your RewriteRule, so you should not include it (or else, the first capture group you are defining doesn't make sense). It should look more like this:

RewriteRule ^dresses/?(.*)$ /apparel-clothes/dresses/$1 [R=301,L]

That will rewrite http://abc.com/dresses to http://abc.com/apparel-clothes/dresses/ and so on.

于 2013-10-17T11:32:37.633 回答