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 - Тарых жана география Навигация менюсу

            Club Baloncesto Breogán Índice Historia | Pavillón | Nome | O Breogán na cultura popular | Xogadores | Adestradores | Presidentes | Palmarés | Historial | Líderes | Notas | Véxase tamén | Menú de navegacióncbbreogan.galCadroGuía oficial da ACB 2009-10, páxina 201Guía oficial ACB 1992, páxina 183. Editorial DB.É de 6.500 espectadores sentados axeitándose á última normativa"Estudiantes Junior, entre as mellores canteiras"o orixinalHemeroteca El Mundo Deportivo, 16 setembro de 1970, páxina 12Historia do BreogánAlfredo Pérez, o último canoneiroHistoria C.B. BreogánHemeroteca de El Mundo DeportivoJimmy Wright, norteamericano do Breogán deixará Lugo por ameazas de morteResultados de Breogán en 1986-87Resultados de Breogán en 1990-91Ficha de Velimir Perasović en acb.comResultados de Breogán en 1994-95Breogán arrasa al Barça. "El Mundo Deportivo", 27 de setembro de 1999, páxina 58CB Breogán - FC BarcelonaA FEB invita a participar nunha nova Liga EuropeaCharlie Bell na prensa estatalMáximos anotadores 2005Tempada 2005-06 : Tódolos Xogadores da Xornada""Non quero pensar nunha man negra, mais pregúntome que está a pasar""o orixinalRaúl López, orgulloso dos xogadores, presume da boa saúde económica do BreogánJulio González confirma que cesa como presidente del BreogánHomenaxe a Lisardo GómezA tempada do rexurdimento celesteEntrevista a Lisardo GómezEl COB dinamita el Pazo para forzar el quinto (69-73)Cafés Candelas, patrocinador del CB Breogán"Suso Lázare, novo presidente do Breogán"o orixinalCafés Candelas Breogán firma el mayor triunfo de la historiaEl Breogán realizará 17 homenajes por su cincuenta aniversario"O Breogán honra ao seu fundador e primeiro presidente"o orixinalMiguel Giao recibiu a homenaxe do PazoHomenaxe aos primeiros gladiadores celestesO home que nos amosa como ver o Breo co corazónTita Franco será homenaxeada polos #50anosdeBreoJulio Vila recibirá unha homenaxe in memoriam polos #50anosdeBreo"O Breogán homenaxeará aos seus aboados máis veteráns"Pechada ovación a «Capi» Sanmartín e Ricardo «Corazón de González»Homenaxe por décadas de informaciónPaco García volve ao Pazo con motivo do 50 aniversario"Resultados y clasificaciones""O Cafés Candelas Breogán, campión da Copa Princesa""O Cafés Candelas Breogán, equipo ACB"C.B. Breogán"Proxecto social"o orixinal"Centros asociados"o orixinalFicha en imdb.comMario Camus trata la recuperación del amor en 'La vieja música', su última película"Páxina web oficial""Club Baloncesto Breogán""C. B. Breogán S.A.D."eehttp://www.fegaba.com

            Vilaño, A Laracha Índice Patrimonio | Lugares e parroquias | Véxase tamén | Menú de navegación43°14′52″N 8°36′03″O / 43.24775, -8.60070