如何将旧的丑陋的网址重定向到新的SEO友好网址?

时间:2017-02-20 13:52:25

标签: .htaccess url mod-rewrite url-rewriting

我真的需要一些帮助来解决这个问题,因为我已经尝试解决这个问题几天了。

我的旧网址看起来像这样: category.php ID = 6&安培;名称= MAXI-礼服&安培;类型= 1 **

我已使用htaccess将其更改为: https://markandroberts.com/category/dresses/maxi-dresses/

正如您所注意到的,在新网址中,我还将类别ID的位置更改为结尾而不是开头。

我现在要做的是将301已经在Google中编入索引的所有旧类别网址重定向到新位置。

这是我目前的htaccess代码:

RewriteEngine on

RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.markandroberts.com/$1 [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

RewriteRule ^product/([0-9]+)/(.*)/(.*)/$^ product.php?id=$1&type=$2&name=$3
RewriteRule ^product/([0-9]+)/(.*)/(.*)/ product.php?id=$1&type=$2&name=$3

RewriteRule ^category/(.*)/(.*)/$^ category.php?type=$1&id=$2
RewriteRule ^category/(.*)/(.*)/ category.php?type=$1&id=$2

RewriteRule ^type/(.*)$/^ main-category.php?maincat=$1
RewriteRule ^type/(.*)/ main-category.php?maincat=$1

RedirectMatch 301 /category.php?id=$1&name=$2&type=$3 /category/$3/$1/

任何有效的解决方案?

0 个答案:

没有答案