1

I am using Magento version 2.2.6

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

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?

2 Answers 2

1

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]
0

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

1
  • I have this type of urls (many different different urls) product.asp?product=977 how to do this ? Commented Nov 19, 2019 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.