I made some changes to the files on a website and now Search Console is showing me 404 errors for some URLs.
The normal setup, which works fine is like this:
the user-friendly URL
mywebsite.com/modeles-voiture/Volvo/XC60
is rewritten to get to the PHP script as:
RewriteCond %{REQUEST_URI} ^/?modeles-voiture [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule \/([A-Z][\-A-Za-z]+)\/([\-A-Za-z0-9\.]+$) /models.php?brand=$1&model=$2 [L]
Now, I do have some old URLs out there, that are generating the 404 errors and that look like:
mywebsite.com/modeles.php?brand=Volvo&model=XC60
So, I came up with the following redirect to send them to the right place.
This first step would redirect the old URLs to the new, user-friendly ones:
RewriteCond %{REQUEST_URI} \/modeles\.php [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule brand=([A-Z][\-A-Za-z]+)&model=([\-A-Za-z0-9\.]+$) http://www.soeezauto.com/modeles-voiture/$1/$2 [R=301,L]
Then, the existing code ( below ), would do its regular job of sending over to the proper PHP script.
So ( just repeating what I stated up on the top ):
RewriteCond %{REQUEST_URI} ^/?modeles-voiture [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule \/([A-Z][\-A-Za-z]+)\/([\-A-Za-z0-9\.]+$) /models.php?brand=$1&model=$2 [L]
My this is not working. Still getting a 404 error.
I did test all the individual regexps ( at regex101.com ) and they seem to do what they are supposed to.
I may just have made the wrong assumption concerning the chaining, but in that case, what is the solution to this?