Home HTACCESS Wordpress 301 redirects query strings
Reply: 0

HTACCESS Wordpress 301 redirects query strings

user3625
1#
user3625 Published in April 24, 2018, 8:39 am

We recently migrated a site to WordPress. To make a good migration we want te 301 redirect all the old URL's to the new URL's.

The old URL's look like this:

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

I tried everything to redirect those pages but nothing worked. Even a redirect to the Homepage is'nt working.

I tried something like this:

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

But no luck. How can I redirect those URL's in a proper way?

I got lucky at one moment but I still got the ?offset=256&pg=20070124 after my URL.

Is there a good way to 301 redirect those URLS?

This is my current 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>
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.356835 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO