尝试做一些301重写,但附加了一个url字符串..
我认为这种情况正在发生,因为我正在使用SEO重写和301重定向?任何有关如何解决此问题的建议都将受到高度赞赏!
问题是:
此网址:domain.nl/meubels/Tafels/Theetafels-en-wijntafels/
应改写为:domain.nl/meubels/tafels/theetafel-wijntafel/
但它改写为:domain.nl/meubels/tafels/theetafel-wijntafel/?activetab=Tafels&cat=Theetafels-en-wijntafels
不应将其添加到网址:?activetab=Tafels&cat=Theetafels-en-wijntafels
我的htaccess文件:
ErrorDocument 404 /error404.php
RewriteRule ^meubels/$ product-listing.php?show=home
RewriteRule meubels/(.*)/(.*)/(.*)/$ product-listing.php?activetab=$1&cat=$2&open=$3
RewriteRule meubels/(.*)/(.*)/$ product-listing.php?activetab=$1&cat=$2
RewriteRule product/(.*)/$ product-detail.php?id=$1
RewriteRule info/(.*)/$ text-page.php?show=$1
RewriteRule info/(.*)/$ text-page.php?show=$1
# DirectoryIndex product-listing.php?cPath=32
Redirect 301 /meubels/Tafels/Theetafels-en-wijntafels/ /meubels/tafels/theetafel-wijntafel/
答案 0 :(得分:2)
RewriteRule ^meubels/Tafels/Theetafels-en-wijntafels/ http://domain.nl/meubels/tafels/theetafel-wijntafel/ [R=301,L]
就像@Liam Bailey所说的那样,在其他重写规则出现之前它应该是最重要的。
答案 1 :(得分:1)
.htaccess在页面上以垂直顺序工作,所以如果你将301移到meubels的重写规则之上,那么它将重定向,然后在友好网址上显示参数化的meubels页面。
ErrorDocument 404 /error404.php
Redirect 301 /meubels/Tafels/Theetafels-en-wijntafels/ /meubels/tafels/theetafel-wijntafel/
RewriteRule ^meubels/$ product-listing.php?show=home
RewriteRule meubels/(.*)/(.*)/(.*)/$ product-listing.php?activetab=$1&cat=$2&open=$3
RewriteRule meubels/(.*)/(.*)/$ product-listing.php?activetab=$1&cat=$2
RewriteRule product/(.*)/$ product-detail.php?id=$1
RewriteRule info/(.*)/$ text-page.php?show=$1
RewriteRule info/(.*)/$ text-page.php?show=$1
# DirectoryIndex product-listing.php?cPath=32
第一次查看htaccess时它将直接重定向到301,然后第二次跳过它并提供重写。如果这不起作用,请在重写规则之上尝试RewriteEngine On
。