2017-02-20 70 views
1

我真的需要一些幫助,因爲我已經試圖解決這個問題已經有好幾天了。如何將舊的醜陋尋找的網址重定向到新的SEO友好的網址?

我有舊網址看起來像這樣: category.php ID = 6 &名稱=馬克西禮服&型= 1 **

我已經改變了他們看起來像這樣使用htaccess的:https://markandroberts.com/category/dresses/maxi-dresses/

正如你可以注意到,在新的網址中,我也改變了類別id的位置,把它放在最後,而不是開頭。

我想現在要做的就是301重定向一切都已經收錄在谷歌到新的位置舊分類的URL。

這裏是我當前的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/ 

作品的任何解決方案?

+1

你能分享你所嘗試過的嗎? – starkeen

+0

分享您爲解決此問題所付出的努力。 –

+0

當然,這是我的htaccess: RedirectMatch 301 /category.php?id=$1&name=$2&type=$3/category/$ 3/$ 1 / – robertnost

回答

0

您需要修改.htaccess文件,包括一些「漂亮網址」規則。 Here就是你的例子。

相關問題