I have to Create a Custom Module for product attribute filter URL rewrite.
Url rewrites are working in a default Magento environment for external redirects, too. You can redirect almost every path of your store that way, because the check for redirects is done before other Magento routers come into action.
Therefore the rewrite in the below screenshot will do the redirect for your example.
This can be caused by duplicate entries for the same product in url_rewrite database table.
You can check duplicate entries using below query.
SELECT * FROM url_rewrite WHERE entity_type = 'product'
To resolve your issue Follow this link
I hope it helps.
After so much debugging, I've found an alternative solution for this issue by creating a custom module to generate the URL rewrite while creating/editing a product from Admin.
Create Vendor/UrlRewriteFix/etc/adminhtml/di.xml and define the plugin class Magento\Catalog\Model\Product in the file.
You can add a custom Router class to match your criteria and then redirect to your desired path
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
It was not there in 2.3 when I needed it. I think they have now removed the config to not regenerate on save... as this was recommended never to be off. I had speed issues with my script to fix and with some modules I tried.
elgentos/regenerate-catalog-urls is the module to use being fast, flexible and reliable. From the readme...
This extension ...
We can configure it by URL Rewrites
Go to Magento 2 Admin -> Marketing -> SEO & Search -> URL Rewrites
Find the path by searching Request path column.
Remove the cache php bin/magento cache:clean.
Refresh the front-end, click the main menu category then you can see the configured path.
Example I have modified.
Request path men/tops-men/tees-men.htm
Referring to question - Magento 2 - Homepage is 404
See if there are any records missing value for request path using below query:
SELECT * FROM `url_rewrite` WHERE request_path='';
Either remove those records or update with valid values.
For above my problem, I seem to have found my solution for that after too much googling.
I have used below extension which is free.
for that particular products i have regenerate product urls again.It working for me correctly.
You can try this for run OlegKoval command in observer
$output = shell_exec('php bin/magento cache:clean');
you can change your command in this, you can try below code in observer file
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$storeManager = $objectManager->get('\Magento\Store\Model\StoreManagerInterface');
To fix it I ran this SQL query below.
SELECT * FROM `url_rewrite` WHERE `request_path` LIKE '%html.html' AND `redirect_type` LIKE '0';
UPDATE `url_rewrite` SET request_path = REPLACE(request_path, '.html.html', '.html') WHERE `request_path` LIKE ('%html.html') AND `redirect_type` LIKE '0';
Or you can install the Elgento module and run its commands as ...
You can do it with the help of url rewrite in magento 1 and 2 both . In magento 2
On the Admin Panel, go to Marketing > SEO & Search> URL Rewrites
Add url rewrite where you can give the request path and the target path.
Clear cache and run indexing then check the path.
Hope it helps!