Good day. Help make a redirect to .html files.

How to do what if we enter mysite/product.php?id_product=N worked redirect to mysite/N-product-name.html , where N is the product ID; Does the future product name change? Example: mysite/N-platbe-zelenoe.html , mysite/N-tovar-krossovki.html .

Now it works like this: if we enter mysite/product.php?id_product=N , then it is redirected to mysite/my-product-name.html :

 RewriteCond %{QUERY_STRING} ^id_product=(.*)$ [NC] RewriteRule ^(.*)$ http://mysite/10005966-product-name.html? [R=301,L] 

    1 answer 1

    By means of .htaccess, this can be done only manually by writing redirect correspondences to all relevant pages of the site.

    This is due to the fact that the CMS used generates links of the form mysite/product.php?id_product=N , where the identifier is determined via id_product .

    To solve your problem, the CMS should give references of the type mysite/N-product_slug , where the identifier will be product_slug (if it is, of course, formed by the CMS). I note that N in this case is most often superfluous. (To avoid the same addresses with the same slugs , many CMS add a unique number to the address - for example, Joomla does this).