I'm currently updating an old website, but I don't know much about htaccess redirects. I made a script to get all the pages of the website and here are some examples:
For pages:
Redirect 301 /index.php?p=1 https://www.example.com/page_slug/
For categories I did the same:
Redirect 301 /index.php?c=1 https://www.example.com/cat_slug/
Now for the product pages. There are some products that are in multiple categories. For example product 1 is visible in category 1 and 2:
index.php?c=1&pr=1
index.php?c=2&pr=1
Those products have a canonical to
index.php?pr=1
For SEO purposes, should I redirect from c=1 and c=2 and from the url without c in it to https://www.example.com/product/product_slug/
? Or should I just redirect from index.php?pr=1
to the new page?
If I have to redirect from all the categories, is there a way to write it without having to write every category for the same product (it's written with a script, so it's not that much work, but there will be a lot of lines in the htaccess file)?
Code already in the file (in an update folder):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /update/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /update/index.php [L]
</IfModule>