1

我在这里尝试做两件事..

  1. 将http://site.com.au/brand.php?pBrand=THENORTHFACE重定向到http://site.com.au/brand/the-north-face (这工作正常)
  2. 将http://site.com.au/listingbrand.php?pBrand=THENORTHFACE重定向到http://site.com.au/brand/the-north-face这不起作用,当重定向 listingbrand.php?pBrand= DOSH 或 pBrand=ATKM,它们都指向第一次重写 the-north-face)。

我如何使每个品牌的第二次重写工作?另外,为每个品牌重复重写是否正确?

RewriteCond %{QUERY_STRING} ^pBrand=THENORTHFACE$ [NC]
RewriteRule ^brand\.php$ /brand/the-north-face/? [R=301,L]
RewriteRule ^listingbrand\.php$ /brand/the-north-face/ [R=301,L]

RewriteCond %{QUERY_STRING} ^pBrand=DOSH$ [NC]
RewriteRule ^brand\.php$ /brand/dosh/? [R=301,L]
RewriteRule ^listingbrand\.php$ /brand/dosh/ [R=301,L]

RewriteCond %{QUERY_STRING} ^pBrand=ATKM$ [NC]
RewriteRule ^brand\.php$ /brand/all-the-kings-men/? [R=301,L]
RewriteRule ^listingbrand\.php$ /brand/all-the-kings-men/ [R=301,L]
4

1 回答 1

1

你有这个规则3次:

RewriteRule ^listingbrand\.php$ ...

which is not using RewriteCond sinceRewriteCond仅适用于 next RewriteRule。实际上,您甚至不需要单独的规则,因为之前RewriteRule可以同时处理brand.phplistingbrand.php在正则表达式中使用 OR。

将您的代码更改为:

RewriteCond %{QUERY_STRING} ^pBrand=THENORTHFACE$ [NC]
RewriteRule ^(brand|listingbrand)\.php$ /brand/the-north-face/? [R=301,L,NC]

RewriteCond %{QUERY_STRING} ^pBrand=DOSH$ [NC]
RewriteRule ^(brand|listingbrand)\.php$ /brand/dosh/? [R=301,L,NC]

RewriteCond %{QUERY_STRING} ^pBrand=ATKM$ [NC]
RewriteRule ^(brand|listingbrand)\.php$ /brand/all-the-kings-men/? [R=301,L,NC]
于 2013-10-02T04:25:47.350 回答