Question: In the Site, product URL is like this: `http://www.test.com/product-url-key`

But when I searching the product then some product URLs are showing like this:

```
http://www.test.com/catalog/product/view/id/2221/product-url-key

```

This is not for all products.

i want to url like this type `http://www.test.com/product-url-key.html`

Answer: 
> 
> **Note: Please take a backup of the database**
> 
> 
> 

To resolve this issue first delete the rows from the "url\_rewrite" table which has 'product' as 'entity\_type'.
You can use below query

```
DELETE FROM `url_rewrite` where entity_type='product'

```

Then install below the extension

> 
> <https://github.com/olegkoval/magento2-regenerate_url_rewrites>
> 
> 
> 

and run the below command.

```
php bin/magento ok:urlrewrites:regenerate --entity-type=product

```

This solution is worked for me, Hopefully, this will help you.
Try this

Marketing > url rewrite > new url rewirte

Request Path "product-url-key"

Target Path "catalog/product/view/id/2221"

Redirect Type "no" 

Save and flush cache

Or

Marketing > url rewrite

search with the "product-url-key" in Request path 
there you will get some idea.

Hope it might help