How to do nginx redirect for dynamic page urls The Next CEO of Stack OverflowIn Nginx, how can I rewrite all http requests to https while maintaining sub-domain?nginx ssl redirectnginx redirect dynamic page urlsNginx Redirect via Proxy, Rewrite and Preserve URLNginx redirect loop with Wordpressnginx redirect several https subdomains to different urlsnginx: ssl verification failed + wrong redirectExclude Let's Encrypt http requests from nginx https redirectNGINX redirect for multiple domainsNginx http to https redirect not working when listening to upstream loadbalancer

Is it my responsibility to learn a new technology in my own time my employer wants to implement?

How easy is it to start Magic from scratch?

When did Lisp start using symbols for arithmetic?

How do I solve this limit?

Apart from "berlinern", do any other German dialects have a corresponding verb?

Opposite of a diet

Inappropriate reference requests from Journal reviewers

Implement the Thanos sorting algorithm

Fastest way to shutdown Ubuntu Mate 18.10

Science fiction (dystopian) short story set after WWIII

Error when running sfdx update to 7.1.3 then sfdx push errors

What makes a siege story/plot interesting?

Why do professional authors make "consistency" mistakes? And how to avoid them?

Why here is plural "We went to the movies last night."

What is meant by a M next to a roman numeral?

Can a single photon have an energy density?

Whats the best way to handle refactoring a big file?

Is the concept of a "numerable" fiber bundle really useful or an empty generalization?

Rotate a column

Natural language into sentence logic

What happens if you roll doubles 3 times then land on "Go to jail?"

How do scammers retract money, while you can’t?

Does it take more energy to get to Venus or to Mars?

How do we know the LHC results are robust?



How to do nginx redirect for dynamic page urls



The Next CEO of Stack OverflowIn Nginx, how can I rewrite all http requests to https while maintaining sub-domain?nginx ssl redirectnginx redirect dynamic page urlsNginx Redirect via Proxy, Rewrite and Preserve URLNginx redirect loop with Wordpressnginx redirect several https subdomains to different urlsnginx: ssl verification failed + wrong redirectExclude Let's Encrypt http requests from nginx https redirectNGINX redirect for multiple domainsNginx http to https redirect not working when listening to upstream loadbalancer










0















I need to change nginx config in a way , that every dynamically generated request is being redirected to main domain.
I'm not sure how to achieve this. Help please!
Not sure if this matters, but I want to add, that traffic goes thru nginx reveser proxy (ssl) to simple web server (nginx)



https://mypage.com/something ->https://mypage.com
https://mypage.com/anything123 ->https://mypage.com
https://mypage.com/randomtext ->https://mypage.com









share|improve this question







New contributor




Greg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1





    How can you tell which request needs to be redirected?

    – Michael Hampton
    Mar 25 at 13:49















0















I need to change nginx config in a way , that every dynamically generated request is being redirected to main domain.
I'm not sure how to achieve this. Help please!
Not sure if this matters, but I want to add, that traffic goes thru nginx reveser proxy (ssl) to simple web server (nginx)



https://mypage.com/something ->https://mypage.com
https://mypage.com/anything123 ->https://mypage.com
https://mypage.com/randomtext ->https://mypage.com









share|improve this question







New contributor




Greg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • 1





    How can you tell which request needs to be redirected?

    – Michael Hampton
    Mar 25 at 13:49













0












0








0








I need to change nginx config in a way , that every dynamically generated request is being redirected to main domain.
I'm not sure how to achieve this. Help please!
Not sure if this matters, but I want to add, that traffic goes thru nginx reveser proxy (ssl) to simple web server (nginx)



https://mypage.com/something ->https://mypage.com
https://mypage.com/anything123 ->https://mypage.com
https://mypage.com/randomtext ->https://mypage.com









share|improve this question







New contributor




Greg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












I need to change nginx config in a way , that every dynamically generated request is being redirected to main domain.
I'm not sure how to achieve this. Help please!
Not sure if this matters, but I want to add, that traffic goes thru nginx reveser proxy (ssl) to simple web server (nginx)



https://mypage.com/something ->https://mypage.com
https://mypage.com/anything123 ->https://mypage.com
https://mypage.com/randomtext ->https://mypage.com






nginx redirect






share|improve this question







New contributor




Greg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Greg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Greg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Mar 25 at 12:49









GregGreg

1




1




New contributor




Greg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Greg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Greg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







  • 1





    How can you tell which request needs to be redirected?

    – Michael Hampton
    Mar 25 at 13:49












  • 1





    How can you tell which request needs to be redirected?

    – Michael Hampton
    Mar 25 at 13:49







1




1





How can you tell which request needs to be redirected?

– Michael Hampton
Mar 25 at 13:49





How can you tell which request needs to be redirected?

– Michael Hampton
Mar 25 at 13:49










2 Answers
2






active

oldest

votes


















0














You could have two location blocks, one for exact match of root directory and the other one for everything else.



location = / 
try_files /index.html = 404;


location /
return 301 /;



rewrite also can be used instead of return (redirect), but will be slower.



 location / 
rewrite ^ / permanent;



Another option is just to have a rewrite for everything (inside server block), without any location blocks. In this method, url will remain as the original url you typed on the browser.



server 
root /xxx/xxx/xx;
server_name mypage.com;
rewrite ^.*$ /index.html;






share|improve this answer






























    -3














    You to force all pages to the main domain?



    this is the php, you can also embed into another page



    <?php
    $url=$_SERVER['HTTP_HOST'];
    if($url!=$_SERVER['SERVER_NAME'])
    header("Location:https://url.host");

    ?>





    share|improve this answer


















    • 1





      This is completely irrelevant. There is no PHP mentioned in the question, and this isn't a site about programming anyway.

      – Michael Hampton
      Mar 25 at 13:49











    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "2"
    ;
    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: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    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
    );



    );






    Greg is a new contributor. Be nice, and check out our Code of Conduct.









    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f959846%2fhow-to-do-nginx-redirect-for-dynamic-page-urls%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









    0














    You could have two location blocks, one for exact match of root directory and the other one for everything else.



    location = / 
    try_files /index.html = 404;


    location /
    return 301 /;



    rewrite also can be used instead of return (redirect), but will be slower.



     location / 
    rewrite ^ / permanent;



    Another option is just to have a rewrite for everything (inside server block), without any location blocks. In this method, url will remain as the original url you typed on the browser.



    server 
    root /xxx/xxx/xx;
    server_name mypage.com;
    rewrite ^.*$ /index.html;






    share|improve this answer



























      0














      You could have two location blocks, one for exact match of root directory and the other one for everything else.



      location = / 
      try_files /index.html = 404;


      location /
      return 301 /;



      rewrite also can be used instead of return (redirect), but will be slower.



       location / 
      rewrite ^ / permanent;



      Another option is just to have a rewrite for everything (inside server block), without any location blocks. In this method, url will remain as the original url you typed on the browser.



      server 
      root /xxx/xxx/xx;
      server_name mypage.com;
      rewrite ^.*$ /index.html;






      share|improve this answer

























        0












        0








        0







        You could have two location blocks, one for exact match of root directory and the other one for everything else.



        location = / 
        try_files /index.html = 404;


        location /
        return 301 /;



        rewrite also can be used instead of return (redirect), but will be slower.



         location / 
        rewrite ^ / permanent;



        Another option is just to have a rewrite for everything (inside server block), without any location blocks. In this method, url will remain as the original url you typed on the browser.



        server 
        root /xxx/xxx/xx;
        server_name mypage.com;
        rewrite ^.*$ /index.html;






        share|improve this answer













        You could have two location blocks, one for exact match of root directory and the other one for everything else.



        location = / 
        try_files /index.html = 404;


        location /
        return 301 /;



        rewrite also can be used instead of return (redirect), but will be slower.



         location / 
        rewrite ^ / permanent;



        Another option is just to have a rewrite for everything (inside server block), without any location blocks. In this method, url will remain as the original url you typed on the browser.



        server 
        root /xxx/xxx/xx;
        server_name mypage.com;
        rewrite ^.*$ /index.html;







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 18 hours ago









        ChamindaChaminda

        312




        312























            -3














            You to force all pages to the main domain?



            this is the php, you can also embed into another page



            <?php
            $url=$_SERVER['HTTP_HOST'];
            if($url!=$_SERVER['SERVER_NAME'])
            header("Location:https://url.host");

            ?>





            share|improve this answer


















            • 1





              This is completely irrelevant. There is no PHP mentioned in the question, and this isn't a site about programming anyway.

              – Michael Hampton
              Mar 25 at 13:49















            -3














            You to force all pages to the main domain?



            this is the php, you can also embed into another page



            <?php
            $url=$_SERVER['HTTP_HOST'];
            if($url!=$_SERVER['SERVER_NAME'])
            header("Location:https://url.host");

            ?>





            share|improve this answer


















            • 1





              This is completely irrelevant. There is no PHP mentioned in the question, and this isn't a site about programming anyway.

              – Michael Hampton
              Mar 25 at 13:49













            -3












            -3








            -3







            You to force all pages to the main domain?



            this is the php, you can also embed into another page



            <?php
            $url=$_SERVER['HTTP_HOST'];
            if($url!=$_SERVER['SERVER_NAME'])
            header("Location:https://url.host");

            ?>





            share|improve this answer













            You to force all pages to the main domain?



            this is the php, you can also embed into another page



            <?php
            $url=$_SERVER['HTTP_HOST'];
            if($url!=$_SERVER['SERVER_NAME'])
            header("Location:https://url.host");

            ?>






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 25 at 13:28









            freddybobjofreddybobjo

            15




            15







            • 1





              This is completely irrelevant. There is no PHP mentioned in the question, and this isn't a site about programming anyway.

              – Michael Hampton
              Mar 25 at 13:49












            • 1





              This is completely irrelevant. There is no PHP mentioned in the question, and this isn't a site about programming anyway.

              – Michael Hampton
              Mar 25 at 13:49







            1




            1





            This is completely irrelevant. There is no PHP mentioned in the question, and this isn't a site about programming anyway.

            – Michael Hampton
            Mar 25 at 13:49





            This is completely irrelevant. There is no PHP mentioned in the question, and this isn't a site about programming anyway.

            – Michael Hampton
            Mar 25 at 13:49










            Greg is a new contributor. Be nice, and check out our Code of Conduct.









            draft saved

            draft discarded


















            Greg is a new contributor. Be nice, and check out our Code of Conduct.












            Greg is a new contributor. Be nice, and check out our Code of Conduct.











            Greg is a new contributor. Be nice, and check out our Code of Conduct.














            Thanks for contributing an answer to Server Fault!


            • 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%2fserverfault.com%2fquestions%2f959846%2fhow-to-do-nginx-redirect-for-dynamic-page-urls%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

            Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

            Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

            What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company