Question

I am using Magento version 2.2.6

I have already tried with Marketing >> URL Rewrite >> Add New URL Rewrite add custom URL but not working when we use it with question mark in URL, it's working with / (slash)

I have URL like this mydomain.com/product.asp?product=977 and I want it to be rewritten to this mydomain.com (redirect to the root of the domain)

Also, I have another example mydomain.com/catalogsearch/result/?q=lim and I want to redirect to this mydomain.com/ingpage/about-lim.html

Can anyone suggest to me how to do this via custom programming in Magento 2?

No correct solution

OTHER TIPS

Please try this I have found that solutions.Below define in root .htaccess file inside code use it

RewriteCond %{QUERY_STRING} ^q=tank123$
RewriteRule ^(index\.php)?$ /mage229/men.html [QSD,R=301,L]

RewriteCond %{QUERY_STRING} ^color=50$
RewriteRule ^(index\.php)?$ /mage229/men/tops-men.html [QSD,R=301,L]

Locate the htaccess configuration file on web servers running the Apache Web Server software and run a command with the below syntax:

Open .htaccess in Magento 2 Root FOlder

Redirect 301 [old URL] [New URL]

Eg:

Redirect 301 oldpath.html newpath.html

Notes* Make sure don't use full URL and put in last

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top