2016-11-29 136 views
0

我們最近將一個站點遷移到WordPress。爲了實現良好的遷移,我們希望te 301將所有舊的URL重定向到新的URL。HTACCESS Wordpress 301重定向查詢字符串

舊的URL是這樣的:

www.website.nl/site/producten.html?offset=256&pg=20070124 

我什麼都試過重定向這些網頁,但毫無效果。即使重定向到主頁也無法正常工作。

我想是這樣的:

RewriteCond %{QUERY_STRING} pg=20070124 
RewriteRule ^producten.html(.*) /producten/? [R=301,L] 

,但沒有運氣。如何以適當的方式重定向這些網址?

我很幸運,但我仍然在我的URL後得到了?offset = 256 & pg = 20070124。

有沒有301重定向這些URL的好方法?

這是我目前的.htaccess

<IfModule mod_rewrite.c> 
RewriteEngine on 
RewriteCond %{HTTPS} !=on 
RewriteRule^https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php 

RewriteCond %{HTTP_HOST} ^www\.(.+)$ 
RewriteRule^https://%1%{REQUEST_URI} [L,R=301] 
</IfModule> 


<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase/
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /index.php [L] 
</IfModule> 


<IfModule mod_rewrite.c> 
RewriteEngine On 
Redirect 301 /site/producten.html https://website.nl/ 
Redirect 301 /site/productenindex.html https://website.nl/ 
Redirect 301 /site/algemene_voorwaarden.html https://website.nl/privacy/ 
Redirect 301 /site/besparen.html https://website.nl/ 
Redirect 301 /site/douche.html https://website.nl/badkamer/ 
Redirect 301 /site/dakgoot.html https://website.nl/dakgoten/ 
Redirect 301 /site/contact.html https://website.nl/contact/ 
Redirect 301 /site/elektra.html https://website.nl/diensten/installatiebedrijf-den-bosch/ 
Redirect 301 /site/radiator.html https://website.nl/cv-ketels/ 
Redirect 301 /site/sanitair.html https://website.nl/badkamer/ 
Redirect 301 /site/schakelmateriaal.html https://website.nl/diensten/installateur-den-bosch/ 
Redirect 301 /site/duurzaam.html https://website.nl/ 
Redirect 301 /site/bad.html https://website.nl/badkamer/ 
Redirect 301 /site/meubelen.html https://website.nl/ 
Redirect 301 /site/boiler.html https://website.nl/cv-ketels/ 
Redirect 301 /site/verlichting.html https://website.nl/ 
Redirect 301 /site/ketel.html https://website.nl/cv-ketels/ 
Redirect 301 /site/leidingen.html https://website.nl/loodgieter/ 
Redirect 301 /site/dakbedekking.html https://website.nl/ 
Redirect 301 /site/afvoer.html https://website.nl/verstoppingen/ 
Redirect 301 /site/toilet.html https://website.nl/loodgieter/ 
Redirect 301 /site/warmteterug.html https://website.nl/cv-ketels/ 
Redirect 301 /site/geiser.html https://website.nl/cv-ketels/ 
Redirect 301 /site/vloer.html https://website.nl/ 
Redirect 301 /site/kranen.html https://website.nl/badkamer/ 
Redirect 301 /site/wastafels.html https://website.nl/badkamer/ 
Redirect 301 /site/zonneenergie.html https://website.nl/ 
Redirect 301 /site/loodgietwerk.html https://website.nl/loodgieter/ 
Redirect 301 /site/verwarming.html https://website.nl/cv-ketels/ 
Redirect 301 /site/convector.html https://website.nl/cv-ketels/ 
Redirect 301 /site/algemeen4.html https://website.nl/ 
Redirect 301 /site/producten/hommage-wastafelonderkast-69x.20412735.html https://website.nl/ 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ /site/producten\.html\?offset=(.+)&pg=([^&\s]+) 
RewriteRule^/producten/? [R=301,L] 

</IfModule> 
+0

ofcourse,我會把它加到我原來的問題 – user2812779

回答

1

嘗試使用要求,如果這是行不通的。

RewriteEngine on 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\ /site/producten\.html\?offset=(.+)&pg=([^&\s]+) 
RewriteRule^/producten/? [R=301,L] 
+0

謝謝你的例子。我嘗試了你的解決方案,它將頁面重定向到我的主頁,但URL仍然是這樣的:https://website.nl/?offset=256&pg=20070124 - 有沒有辦法從URL中刪除這個? – user2812779

+1

你確定嗎?清除緩存,RewriteRule末尾的問號告訴它放棄查詢字符串。確保那裏。 –