A simple 301 redirect is not working in this instance - For example:
Redirect 301 /oldpage http://www.mysite.co.uk/newsubdir/newpage
The site is dynamic and the .htaccess is already renaming pages to search engine friendly URL's from URL's containing a query string.
RewriteRule ^(.*)/(.*)$ index.php?page_name=$1&sub=$2 [NC,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)([^/])$ http://www.mysite.co.uk/$1$2/ [R=301,L]
When we are using these 301 redirects like above in the same .htaccess (at the bottom), the pages are redirecting but the query string is getting added to the end of the URL frustratingly and we have not figured out why or how to prevent it.
After 301 redirect, URL is looking like:-
http://www.mysite.co.uk/newsubdir/newpage/?page_name=old-page&sub=
...Causing a 404 error - it's just the query string added on the end of the URL's that is breaking the redirect.
Please can anyone advise on what needs to be done to fix this?
Thanks