URL redirect rules adding firstvar=&secondvar=

58
June 15, 2018, at 12:40 PM

I have a problem with my website's htaccess file and rewrite rule.

This code below handles my page links

RewriteRule  ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$  index.php?firstvar=$1&secondvar=$2    [NC,L]
RewriteRule  ^([A-Za-z0-9-]+)/?$  index.php?firstvar=$1 [NC]
RewriteRule  ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$  index.php?firstvar=$1&secondvar=$2&thirdvar=$3&fourthvar=$4    [NC,L]
RewriteRule  ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$  index.php?firstvar=$1&secondvar=$2&thirdvar=$3&fourthvar=$4&fifthvar=$5    [NC,L]
RewriteRule  ^([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$  index.php?firstvar=$1&secondvar=$2&thirdvar=$3&fourthvar=$4&fifthvar=$5&sixthvar=$6    [NC,L]

The problem I am having is that whenever I try to redirect one page to the other it will add additional characters that search engines will pick up.

Example

If I try to redirect example.com/2442/18-title to example.com/2442/40-title

then I will see example.com/2442/18-title?firstvar=2442&secondvar=40-title

adding ?firstvar=2442&secondvar=

Please what I need is to just redirect it to example.com/2442/18-title without adding ?firstvar=2442&secondvar= at the middle making it another URL altogether which search engine picks and adds to duplicate URL

Please before your advice I want to let you know that the above code handles the inner URL and if I remove it the URL will break

Thanks in advance

READ ALSO
Pass affiliate ID as parameter on URL

Pass affiliate ID as parameter on URL

I'm looking for help trying to track the affiliate ID associated with an application submitted on my wordpress site

97
CVX solver will not run in MATLAB when called from php

CVX solver will not run in MATLAB when called from php

I have the following PHP script that calls a MATLAB script

80
CSV not importing to mySQLi

CSV not importing to mySQLi

I'm trying to import an CSV into mySQL, I'm very new to this, but to my knowledge I've followed exactly what another post on stackoverflow has said and it's still not working

108
How to get rows (row by row) of multiple tables by the old date

How to get rows (row by row) of multiple tables by the old date

I'm using Laravel ,for example I have 3 Models , and I get the data recorded by the current user as follows:

71