Answer the question
In order to leave comments, you need to log in
How to get rid of duplicate link with GET parameter?
Hello, I am without preludes.
The old links look like:
site.com/product.php?article=PP620
Added one more parameter to the product name link so that the keywords appear in the link and get the following:
site.com/product.php?article=PP620&name=arduino-uno
After converting a link to CNC with two parameters I get:
site.com/PP620/arduino-uno.html
But there are still two types of links to the same product, namely: a link with one parameter and a link converted to CNC.
How can I redirect from a link with one GET to a link with two GET ?
Here is my code which converts and redirects without infinite redirect. Help with a hint, modify the code or do you need to add a condition?
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} ^article=([^&]*)&name=([^&]*)
RewriteRule ^product\.php$ /%1/%2.html? [R=301,L]
RewriteRule ^([^/]*)/([^/]*)\.html$ /product.php?article=$1&name=$2 [L]
Answer the question
In order to leave comments, you need to log in
If I were you, I would separate the Queri separately
so that it will be possible to work with the conditions.
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{QUERY_STRING} (^)article\=(.+[^&])$
RewriteCond %{QUERY_STRING} (^|&)name=($|&)
RewriteRule ^product\.php$ /%1/%2.html? [R=301,L]
RewriteRule ^([^/]*)/([^/]*)\.html$ /product.php\?article=$1&name=$2 [L]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question