Magento 2 query url rewriteMagento 2 Make GET Request url to rewrite acceptableOptimize catalog product url...

Why did Luke use his left hand to shoot?

Why is 'diphthong' pronounced the way it is?

Does diversity provide anything that meritocracy does not?

In Linux what happens if 1000 files in a directory are moved to another location while another 300 files were added to the source directory?

Book where a space ship journeys to the center of the galaxy to find all the stars had gone supernova

I have trouble understanding this fallacy: "If A, then B. Therefore if not-B, then not-A."

How would an AI self awareness kill switch work?

What game did these black and yellow dice come from?

What's the oldest plausible frozen specimen for a Jurassic Park style story-line?

How can I play a serial killer in a party of good PCs?

Does the ditching switch allow an A320 to float indefinitely?

What can I do to encourage my players to use their consumables?

How to not let the Identify spell spoil everything?

Calculate the true diameter of stars from photographic plate

Do authors have to be politically correct in article-writing?

Subsurf on a crown. How can I smooth some edges and keep others sharp?

After checking in online, how do I know whether I need to go show my passport at airport check-in?

What is the difference between "...", '...', $'...', and $"..." quotes?

Microtypography protrusion with Polish quotation marks

What essential properties make us human?

What is the industry term for house wiring diagrams?

What species should be used for storage of human minds?

Why avoid shared user accounts?

Why maximum length of IP, TCP, UDP packet is not suit?



Magento 2 query url rewrite


Magento 2 Make GET Request url to rewrite acceptableOptimize catalog product url rewriteWeb Server (Apache) Rewrites on NGINXMagento 2 URL rewrite Indexcustom url rewriteMagento 2 multi website url setupMagento 2 url rewrite cann't work with querystringMagento 2.1: Modifying root .htaccess for URL rewrite rulesMagento1.9 - How to rewrite exact url using xmlI still have access to normal urls when rewrite urls is activeMagento 2 custom url rewrite ignores query string













2















If I have URL like this -




mainpage.com/products?test_category=99




and want it to be rewritten to this




mainpage.com/testproducts




Since magento2 URL rewrite won't take query how can this be achieved with apache and nginx rewrites?










share|improve this question

























  • url_key for the category?

    – Philipp Sander
    Feb 21 at 10:08











  • url_key for category is products and page is loaded by given collection id which in this case is 99. so mainpage.com/products is given this query ?test_category=99 to load collection on this url mainpage.com/products?test_category=99 which needs to be rewriten

    – Trenox
    Feb 21 at 10:17











  • rewriteing mainpage.com/products?test_category=99 to mainpage.com/testproducts is easy in Apache or Nginx, what are other cases? Are there other parameters than test_category? What should happen with the values? Can you generalize the requirements for the rule you need?

    – HelgeB
    Feb 21 at 10:34











  • There are many pages whose collections are generated like this. But rewrite is only needed for this specific url with param 99

    – Trenox
    Feb 21 at 14:20
















2















If I have URL like this -




mainpage.com/products?test_category=99




and want it to be rewritten to this




mainpage.com/testproducts




Since magento2 URL rewrite won't take query how can this be achieved with apache and nginx rewrites?










share|improve this question

























  • url_key for the category?

    – Philipp Sander
    Feb 21 at 10:08











  • url_key for category is products and page is loaded by given collection id which in this case is 99. so mainpage.com/products is given this query ?test_category=99 to load collection on this url mainpage.com/products?test_category=99 which needs to be rewriten

    – Trenox
    Feb 21 at 10:17











  • rewriteing mainpage.com/products?test_category=99 to mainpage.com/testproducts is easy in Apache or Nginx, what are other cases? Are there other parameters than test_category? What should happen with the values? Can you generalize the requirements for the rule you need?

    – HelgeB
    Feb 21 at 10:34











  • There are many pages whose collections are generated like this. But rewrite is only needed for this specific url with param 99

    – Trenox
    Feb 21 at 14:20














2












2








2








If I have URL like this -




mainpage.com/products?test_category=99




and want it to be rewritten to this




mainpage.com/testproducts




Since magento2 URL rewrite won't take query how can this be achieved with apache and nginx rewrites?










share|improve this question
















If I have URL like this -




mainpage.com/products?test_category=99




and want it to be rewritten to this




mainpage.com/testproducts




Since magento2 URL rewrite won't take query how can this be achieved with apache and nginx rewrites?







magento2 url-rewrite nginx query apache






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 21 at 14:51









Tajveez Rehman

478




478










asked Feb 21 at 10:00









TrenoxTrenox

1069




1069













  • url_key for the category?

    – Philipp Sander
    Feb 21 at 10:08











  • url_key for category is products and page is loaded by given collection id which in this case is 99. so mainpage.com/products is given this query ?test_category=99 to load collection on this url mainpage.com/products?test_category=99 which needs to be rewriten

    – Trenox
    Feb 21 at 10:17











  • rewriteing mainpage.com/products?test_category=99 to mainpage.com/testproducts is easy in Apache or Nginx, what are other cases? Are there other parameters than test_category? What should happen with the values? Can you generalize the requirements for the rule you need?

    – HelgeB
    Feb 21 at 10:34











  • There are many pages whose collections are generated like this. But rewrite is only needed for this specific url with param 99

    – Trenox
    Feb 21 at 14:20



















  • url_key for the category?

    – Philipp Sander
    Feb 21 at 10:08











  • url_key for category is products and page is loaded by given collection id which in this case is 99. so mainpage.com/products is given this query ?test_category=99 to load collection on this url mainpage.com/products?test_category=99 which needs to be rewriten

    – Trenox
    Feb 21 at 10:17











  • rewriteing mainpage.com/products?test_category=99 to mainpage.com/testproducts is easy in Apache or Nginx, what are other cases? Are there other parameters than test_category? What should happen with the values? Can you generalize the requirements for the rule you need?

    – HelgeB
    Feb 21 at 10:34











  • There are many pages whose collections are generated like this. But rewrite is only needed for this specific url with param 99

    – Trenox
    Feb 21 at 14:20

















url_key for the category?

– Philipp Sander
Feb 21 at 10:08





url_key for the category?

– Philipp Sander
Feb 21 at 10:08













url_key for category is products and page is loaded by given collection id which in this case is 99. so mainpage.com/products is given this query ?test_category=99 to load collection on this url mainpage.com/products?test_category=99 which needs to be rewriten

– Trenox
Feb 21 at 10:17





url_key for category is products and page is loaded by given collection id which in this case is 99. so mainpage.com/products is given this query ?test_category=99 to load collection on this url mainpage.com/products?test_category=99 which needs to be rewriten

– Trenox
Feb 21 at 10:17













rewriteing mainpage.com/products?test_category=99 to mainpage.com/testproducts is easy in Apache or Nginx, what are other cases? Are there other parameters than test_category? What should happen with the values? Can you generalize the requirements for the rule you need?

– HelgeB
Feb 21 at 10:34





rewriteing mainpage.com/products?test_category=99 to mainpage.com/testproducts is easy in Apache or Nginx, what are other cases? Are there other parameters than test_category? What should happen with the values? Can you generalize the requirements for the rule you need?

– HelgeB
Feb 21 at 10:34













There are many pages whose collections are generated like this. But rewrite is only needed for this specific url with param 99

– Trenox
Feb 21 at 14:20





There are many pages whose collections are generated like this. But rewrite is only needed for this specific url with param 99

– Trenox
Feb 21 at 14:20










2 Answers
2






active

oldest

votes


















1














For apache you can use the following - for example just put it into your .htaccess file in the document root directory:



RewriteCond %{REQUEST_URI} ^/products.*$
RewriteCond %{QUERY_STRING} ^.*test_category=99.*$
RewriteRule .* /testproducts? [R=301,NC,L]


This does a 301 redirect. If you just want to serve the content (i.e. internal rediect so the client still sees the original URL) please remove R=301 from the rule's option list.



The question mark at the end of the rewrite url means that the query string will entirely be removed (even if there are other parameter except the test_category)



Update: For the updated requirement that /products?test_category=99 should redirect to /testproducts and this page should server the content from /products?test_category=99. In order to avoid endless redirect loops, we need to append a parameter for the internal redirect which helps us to skip the first redirect rule. If the parameter redirected=1 is a problem for the /products URL choose one which fits.



#Redirect /products?test_category=99 to /testproducts
RewriteCond %{REQUEST_URI} ^/products.*$
RewriteCond %{QUERY_STRING} ^.*test_category=99.*$
RewriteCond %{QUERY_STRING} !^test_category=99&redirected=1$
RewriteRule .* /testproducts? [R=301,NC,L]

#Serve content from /products?test_category=99 for /testproducts
RewriteCond %{REQUEST_URI} ^/testproducts$
RewriteRule .* /products?test_category=99&redirected=1 [NC,L]


Update for URLs that have to pass the Magento routing: In this case the REQUEST_URI is used by Magento and this will not be overwritten by the last rule in the example above. A solution in this case is to use the P-flag for the RewriteRule. In this case the Apacehe mod_proxy module needs to be installed!



RewriteRule .* /products?test_category=99&redirected=1 [NC,P]


Update with a better variant using Magento's rewrite routing for the second rewrite /testproducts to /products?test_category=99: Just add a url rewrite with request_path = 'testproducts' and target_path = 'products/test_category/99' and in Apache's .htaccess file only the first RewriteRule is needed.



I hope that helps.






share|improve this answer


























  • unfortunately this did nothing

    – Trenox
    Feb 21 at 15:02











  • Sorry I've copied the wrong one first time in my answer, I have updated it, the query_string needs to be separately

    – HelgeB
    Feb 21 at 17:01











  • will try this tommorow and update if it works. Cheers

    – Trenox
    Feb 21 at 17:06











  • Now if going to this mainpage.com/products?test_category=99 Url rewrites to mainpage.com/testproducts, but the content of first url is not loaded on the second url, so I'm prompted with 404. And When going directly to mainpage.com/testproducts 404 aswell.

    – Trenox
    Feb 22 at 6:41











  • So you want to redirect from mainpage.com/products?test_category=99 to mainpage.com/testproducts and mainpage.com/testproducts should serve the content from mainpage.com/products?test_category=99? Is that right? If yes it will become a little more complex :-)

    – HelgeB
    Feb 22 at 7:23



















0














location / {
if ($arg_test_category = 99 ) {
return 301 https://mainpage.com/testproducts;
}
try_files $uri $uri/ /index.php$is_args$args;
}





share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f262818%2fmagento-2-query-url-rewrite%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    For apache you can use the following - for example just put it into your .htaccess file in the document root directory:



    RewriteCond %{REQUEST_URI} ^/products.*$
    RewriteCond %{QUERY_STRING} ^.*test_category=99.*$
    RewriteRule .* /testproducts? [R=301,NC,L]


    This does a 301 redirect. If you just want to serve the content (i.e. internal rediect so the client still sees the original URL) please remove R=301 from the rule's option list.



    The question mark at the end of the rewrite url means that the query string will entirely be removed (even if there are other parameter except the test_category)



    Update: For the updated requirement that /products?test_category=99 should redirect to /testproducts and this page should server the content from /products?test_category=99. In order to avoid endless redirect loops, we need to append a parameter for the internal redirect which helps us to skip the first redirect rule. If the parameter redirected=1 is a problem for the /products URL choose one which fits.



    #Redirect /products?test_category=99 to /testproducts
    RewriteCond %{REQUEST_URI} ^/products.*$
    RewriteCond %{QUERY_STRING} ^.*test_category=99.*$
    RewriteCond %{QUERY_STRING} !^test_category=99&redirected=1$
    RewriteRule .* /testproducts? [R=301,NC,L]

    #Serve content from /products?test_category=99 for /testproducts
    RewriteCond %{REQUEST_URI} ^/testproducts$
    RewriteRule .* /products?test_category=99&redirected=1 [NC,L]


    Update for URLs that have to pass the Magento routing: In this case the REQUEST_URI is used by Magento and this will not be overwritten by the last rule in the example above. A solution in this case is to use the P-flag for the RewriteRule. In this case the Apacehe mod_proxy module needs to be installed!



    RewriteRule .* /products?test_category=99&redirected=1 [NC,P]


    Update with a better variant using Magento's rewrite routing for the second rewrite /testproducts to /products?test_category=99: Just add a url rewrite with request_path = 'testproducts' and target_path = 'products/test_category/99' and in Apache's .htaccess file only the first RewriteRule is needed.



    I hope that helps.






    share|improve this answer


























    • unfortunately this did nothing

      – Trenox
      Feb 21 at 15:02











    • Sorry I've copied the wrong one first time in my answer, I have updated it, the query_string needs to be separately

      – HelgeB
      Feb 21 at 17:01











    • will try this tommorow and update if it works. Cheers

      – Trenox
      Feb 21 at 17:06











    • Now if going to this mainpage.com/products?test_category=99 Url rewrites to mainpage.com/testproducts, but the content of first url is not loaded on the second url, so I'm prompted with 404. And When going directly to mainpage.com/testproducts 404 aswell.

      – Trenox
      Feb 22 at 6:41











    • So you want to redirect from mainpage.com/products?test_category=99 to mainpage.com/testproducts and mainpage.com/testproducts should serve the content from mainpage.com/products?test_category=99? Is that right? If yes it will become a little more complex :-)

      – HelgeB
      Feb 22 at 7:23
















    1














    For apache you can use the following - for example just put it into your .htaccess file in the document root directory:



    RewriteCond %{REQUEST_URI} ^/products.*$
    RewriteCond %{QUERY_STRING} ^.*test_category=99.*$
    RewriteRule .* /testproducts? [R=301,NC,L]


    This does a 301 redirect. If you just want to serve the content (i.e. internal rediect so the client still sees the original URL) please remove R=301 from the rule's option list.



    The question mark at the end of the rewrite url means that the query string will entirely be removed (even if there are other parameter except the test_category)



    Update: For the updated requirement that /products?test_category=99 should redirect to /testproducts and this page should server the content from /products?test_category=99. In order to avoid endless redirect loops, we need to append a parameter for the internal redirect which helps us to skip the first redirect rule. If the parameter redirected=1 is a problem for the /products URL choose one which fits.



    #Redirect /products?test_category=99 to /testproducts
    RewriteCond %{REQUEST_URI} ^/products.*$
    RewriteCond %{QUERY_STRING} ^.*test_category=99.*$
    RewriteCond %{QUERY_STRING} !^test_category=99&redirected=1$
    RewriteRule .* /testproducts? [R=301,NC,L]

    #Serve content from /products?test_category=99 for /testproducts
    RewriteCond %{REQUEST_URI} ^/testproducts$
    RewriteRule .* /products?test_category=99&redirected=1 [NC,L]


    Update for URLs that have to pass the Magento routing: In this case the REQUEST_URI is used by Magento and this will not be overwritten by the last rule in the example above. A solution in this case is to use the P-flag for the RewriteRule. In this case the Apacehe mod_proxy module needs to be installed!



    RewriteRule .* /products?test_category=99&redirected=1 [NC,P]


    Update with a better variant using Magento's rewrite routing for the second rewrite /testproducts to /products?test_category=99: Just add a url rewrite with request_path = 'testproducts' and target_path = 'products/test_category/99' and in Apache's .htaccess file only the first RewriteRule is needed.



    I hope that helps.






    share|improve this answer


























    • unfortunately this did nothing

      – Trenox
      Feb 21 at 15:02











    • Sorry I've copied the wrong one first time in my answer, I have updated it, the query_string needs to be separately

      – HelgeB
      Feb 21 at 17:01











    • will try this tommorow and update if it works. Cheers

      – Trenox
      Feb 21 at 17:06











    • Now if going to this mainpage.com/products?test_category=99 Url rewrites to mainpage.com/testproducts, but the content of first url is not loaded on the second url, so I'm prompted with 404. And When going directly to mainpage.com/testproducts 404 aswell.

      – Trenox
      Feb 22 at 6:41











    • So you want to redirect from mainpage.com/products?test_category=99 to mainpage.com/testproducts and mainpage.com/testproducts should serve the content from mainpage.com/products?test_category=99? Is that right? If yes it will become a little more complex :-)

      – HelgeB
      Feb 22 at 7:23














    1












    1








    1







    For apache you can use the following - for example just put it into your .htaccess file in the document root directory:



    RewriteCond %{REQUEST_URI} ^/products.*$
    RewriteCond %{QUERY_STRING} ^.*test_category=99.*$
    RewriteRule .* /testproducts? [R=301,NC,L]


    This does a 301 redirect. If you just want to serve the content (i.e. internal rediect so the client still sees the original URL) please remove R=301 from the rule's option list.



    The question mark at the end of the rewrite url means that the query string will entirely be removed (even if there are other parameter except the test_category)



    Update: For the updated requirement that /products?test_category=99 should redirect to /testproducts and this page should server the content from /products?test_category=99. In order to avoid endless redirect loops, we need to append a parameter for the internal redirect which helps us to skip the first redirect rule. If the parameter redirected=1 is a problem for the /products URL choose one which fits.



    #Redirect /products?test_category=99 to /testproducts
    RewriteCond %{REQUEST_URI} ^/products.*$
    RewriteCond %{QUERY_STRING} ^.*test_category=99.*$
    RewriteCond %{QUERY_STRING} !^test_category=99&redirected=1$
    RewriteRule .* /testproducts? [R=301,NC,L]

    #Serve content from /products?test_category=99 for /testproducts
    RewriteCond %{REQUEST_URI} ^/testproducts$
    RewriteRule .* /products?test_category=99&redirected=1 [NC,L]


    Update for URLs that have to pass the Magento routing: In this case the REQUEST_URI is used by Magento and this will not be overwritten by the last rule in the example above. A solution in this case is to use the P-flag for the RewriteRule. In this case the Apacehe mod_proxy module needs to be installed!



    RewriteRule .* /products?test_category=99&redirected=1 [NC,P]


    Update with a better variant using Magento's rewrite routing for the second rewrite /testproducts to /products?test_category=99: Just add a url rewrite with request_path = 'testproducts' and target_path = 'products/test_category/99' and in Apache's .htaccess file only the first RewriteRule is needed.



    I hope that helps.






    share|improve this answer















    For apache you can use the following - for example just put it into your .htaccess file in the document root directory:



    RewriteCond %{REQUEST_URI} ^/products.*$
    RewriteCond %{QUERY_STRING} ^.*test_category=99.*$
    RewriteRule .* /testproducts? [R=301,NC,L]


    This does a 301 redirect. If you just want to serve the content (i.e. internal rediect so the client still sees the original URL) please remove R=301 from the rule's option list.



    The question mark at the end of the rewrite url means that the query string will entirely be removed (even if there are other parameter except the test_category)



    Update: For the updated requirement that /products?test_category=99 should redirect to /testproducts and this page should server the content from /products?test_category=99. In order to avoid endless redirect loops, we need to append a parameter for the internal redirect which helps us to skip the first redirect rule. If the parameter redirected=1 is a problem for the /products URL choose one which fits.



    #Redirect /products?test_category=99 to /testproducts
    RewriteCond %{REQUEST_URI} ^/products.*$
    RewriteCond %{QUERY_STRING} ^.*test_category=99.*$
    RewriteCond %{QUERY_STRING} !^test_category=99&redirected=1$
    RewriteRule .* /testproducts? [R=301,NC,L]

    #Serve content from /products?test_category=99 for /testproducts
    RewriteCond %{REQUEST_URI} ^/testproducts$
    RewriteRule .* /products?test_category=99&redirected=1 [NC,L]


    Update for URLs that have to pass the Magento routing: In this case the REQUEST_URI is used by Magento and this will not be overwritten by the last rule in the example above. A solution in this case is to use the P-flag for the RewriteRule. In this case the Apacehe mod_proxy module needs to be installed!



    RewriteRule .* /products?test_category=99&redirected=1 [NC,P]


    Update with a better variant using Magento's rewrite routing for the second rewrite /testproducts to /products?test_category=99: Just add a url rewrite with request_path = 'testproducts' and target_path = 'products/test_category/99' and in Apache's .htaccess file only the first RewriteRule is needed.



    I hope that helps.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited 3 hours ago

























    answered Feb 21 at 14:46









    HelgeBHelgeB

    1,413114




    1,413114













    • unfortunately this did nothing

      – Trenox
      Feb 21 at 15:02











    • Sorry I've copied the wrong one first time in my answer, I have updated it, the query_string needs to be separately

      – HelgeB
      Feb 21 at 17:01











    • will try this tommorow and update if it works. Cheers

      – Trenox
      Feb 21 at 17:06











    • Now if going to this mainpage.com/products?test_category=99 Url rewrites to mainpage.com/testproducts, but the content of first url is not loaded on the second url, so I'm prompted with 404. And When going directly to mainpage.com/testproducts 404 aswell.

      – Trenox
      Feb 22 at 6:41











    • So you want to redirect from mainpage.com/products?test_category=99 to mainpage.com/testproducts and mainpage.com/testproducts should serve the content from mainpage.com/products?test_category=99? Is that right? If yes it will become a little more complex :-)

      – HelgeB
      Feb 22 at 7:23



















    • unfortunately this did nothing

      – Trenox
      Feb 21 at 15:02











    • Sorry I've copied the wrong one first time in my answer, I have updated it, the query_string needs to be separately

      – HelgeB
      Feb 21 at 17:01











    • will try this tommorow and update if it works. Cheers

      – Trenox
      Feb 21 at 17:06











    • Now if going to this mainpage.com/products?test_category=99 Url rewrites to mainpage.com/testproducts, but the content of first url is not loaded on the second url, so I'm prompted with 404. And When going directly to mainpage.com/testproducts 404 aswell.

      – Trenox
      Feb 22 at 6:41











    • So you want to redirect from mainpage.com/products?test_category=99 to mainpage.com/testproducts and mainpage.com/testproducts should serve the content from mainpage.com/products?test_category=99? Is that right? If yes it will become a little more complex :-)

      – HelgeB
      Feb 22 at 7:23

















    unfortunately this did nothing

    – Trenox
    Feb 21 at 15:02





    unfortunately this did nothing

    – Trenox
    Feb 21 at 15:02













    Sorry I've copied the wrong one first time in my answer, I have updated it, the query_string needs to be separately

    – HelgeB
    Feb 21 at 17:01





    Sorry I've copied the wrong one first time in my answer, I have updated it, the query_string needs to be separately

    – HelgeB
    Feb 21 at 17:01













    will try this tommorow and update if it works. Cheers

    – Trenox
    Feb 21 at 17:06





    will try this tommorow and update if it works. Cheers

    – Trenox
    Feb 21 at 17:06













    Now if going to this mainpage.com/products?test_category=99 Url rewrites to mainpage.com/testproducts, but the content of first url is not loaded on the second url, so I'm prompted with 404. And When going directly to mainpage.com/testproducts 404 aswell.

    – Trenox
    Feb 22 at 6:41





    Now if going to this mainpage.com/products?test_category=99 Url rewrites to mainpage.com/testproducts, but the content of first url is not loaded on the second url, so I'm prompted with 404. And When going directly to mainpage.com/testproducts 404 aswell.

    – Trenox
    Feb 22 at 6:41













    So you want to redirect from mainpage.com/products?test_category=99 to mainpage.com/testproducts and mainpage.com/testproducts should serve the content from mainpage.com/products?test_category=99? Is that right? If yes it will become a little more complex :-)

    – HelgeB
    Feb 22 at 7:23





    So you want to redirect from mainpage.com/products?test_category=99 to mainpage.com/testproducts and mainpage.com/testproducts should serve the content from mainpage.com/products?test_category=99? Is that right? If yes it will become a little more complex :-)

    – HelgeB
    Feb 22 at 7:23













    0














    location / {
    if ($arg_test_category = 99 ) {
    return 301 https://mainpage.com/testproducts;
    }
    try_files $uri $uri/ /index.php$is_args$args;
    }





    share|improve this answer




























      0














      location / {
      if ($arg_test_category = 99 ) {
      return 301 https://mainpage.com/testproducts;
      }
      try_files $uri $uri/ /index.php$is_args$args;
      }





      share|improve this answer


























        0












        0








        0







        location / {
        if ($arg_test_category = 99 ) {
        return 301 https://mainpage.com/testproducts;
        }
        try_files $uri $uri/ /index.php$is_args$args;
        }





        share|improve this answer













        location / {
        if ($arg_test_category = 99 ) {
        return 301 https://mainpage.com/testproducts;
        }
        try_files $uri $uri/ /index.php$is_args$args;
        }






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Feb 21 at 10:57









        Daniel V.Daniel V.

        41227




        41227






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f262818%2fmagento-2-query-url-rewrite%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            迭戈·戈丁...

            A phrase ”follow into" in a context The 2019 Stack Overflow Developer Survey Results Are...

            1960s short story making fun of James Bond-style spy fiction The 2019 Stack Overflow Developer...