I've been searching for hours now but cannot find the working solution for this problem. I'm redesigning a website and need to redirect a bunch of old url's to new url's. The basic format is something like:pages/page.php?m=22&p=33
should go to something like mainpage/subpage/
while completely ignoring all parameters. After having tried multiple variations I currently have this (as part of a Wordpress site) in my htaccess. The problem arises when having 2 parameters in the url to redirect instead of 1 or none.
# REDIRECTS FROM OLD WEBSITE
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# custom redirects
Options +FollowSymLinks -MultiViews
RewriteCond %{QUERY_STRING} ^m=([0-9]+)&p=([0-9]+)$ [nc]
RewriteRule ^pages/all_inclusive_zeildag\.php$ /bedrijfsuitjes/volledig\-verzorgd\-zeilen/ [R=301,NC,L]
</IfModule>
# END REDIRECTS OLD WEBSITE
# BEGIN WordPress
all the usual wp code
#
# END WordPress
I have almost got this working. Problem is the second parameter. Properly redirected are: pages/all_inclusive_zeildag.php?m=8 and if I redirect without any parameter at all.
But the problem is:/pages/all_inclusive_zeildag.php?m=8&p=22 which leads to a 404
Any insight are more than welcome.
Thanks, John
A "nice" way to see what is happening while processing the rewrite rules is using the RewriteLog and RewriteLogLevel directives in Apache 2.2 mod_rewrite:
Or in Apache 2.4 mod_rewrite using the regular LogLevel directive:
See also: https://wiki.apache.org/httpd/RewriteLog, https://stackoverflow.com/a/9632952/832620