【发布时间】:2017-02-20 13:52:25
【问题描述】:
我真的需要一些帮助来解决这个问题,因为我已经尝试解决这个问题几天了。
我的旧网址看起来像这样: category.php?id=6&name=maxi-dresses&type=1**
我已使用 htaccess 将它们更改为如下所示:https://markandroberts.com/category/dresses/maxi-dresses/
您可以注意到,在新的 url 中,我还更改了类别 ID 的位置,将其放在末尾而不是开头。
我现在要做的是将所有已在 Google 中编入索引的旧类别 URL 301 重定向到新位置。
这是我当前的 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/
任何有效的解决方案?
【问题讨论】:
-
你能分享你的尝试吗?
-
分享你为解决这个问题付出的努力。
-
当然,这是我的 htaccess:RedirectMatch 301 /category.php?id=$1&name=$2&type=$3 /category/$3/$1/
标签: .htaccess url mod-rewrite url-rewriting