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

Multi tool use
Multi tool use

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







            KBQuvw0gj6tzIG3duBXt8puFR8y45zJtiKBOTwTalvW,f,Eps4pJ,ig75HkpeJdbgFc
            LfkPzevQ

            Popular posts from this blog

            RemoteApp sporadic failureWindows 2008 RemoteAPP client disconnects within a matter of minutesWhat is the minimum version of RDP supported by Server 2012 RDS?How to configure a Remoteapp server to increase stabilityMicrosoft RemoteApp Active SessionRDWeb TS connection broken for some users post RemoteApp certificate changeRemote Desktop Licensing, RemoteAPPRDS 2012 R2 some users are not able to logon after changed date and time on Connection BrokersWhat happens during Remote Desktop logon, and is there any logging?After installing RDS on WinServer 2016 I still can only connect with two users?RD Connection via RDGW to Session host is not connecting

            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

            Cegueira Índice Epidemioloxía | Deficiencia visual | Tipos de cegueira | Principais causas de cegueira | Tratamento | Técnicas de adaptación e axudas | Vida dos cegos | Primeiros auxilios | Crenzas respecto das persoas cegas | Crenzas das persoas cegas | O neno deficiente visual | Aspectos psicolóxicos da cegueira | Notas | Véxase tamén | Menú de navegación54.054.154.436928256blindnessDicionario da Real Academia GalegaPortal das Palabras"International Standards: Visual Standards — Aspects and Ranges of Vision Loss with Emphasis on Population Surveys.""Visual impairment and blindness""Presentan un plan para previr a cegueira"o orixinalACCDV Associació Catalana de Cecs i Disminuïts Visuals - PMFTrachoma"Effect of gene therapy on visual function in Leber's congenital amaurosis"1844137110.1056/NEJMoa0802268Cans guía - os mellores amigos dos cegosArquivadoEscola de cans guía para cegos en Mortágua, PortugalArquivado"Tecnología para ciegos y deficientes visuales. Recopilación de recursos gratuitos en la Red""Colorino""‘COL.diesis’, escuchar los sonidos del color""COL.diesis: Transforming Colour into Melody and Implementing the Result in a Colour Sensor Device"o orixinal"Sistema de desarrollo de sinestesia color-sonido para invidentes utilizando un protocolo de audio""Enseñanza táctil - geometría y color. Juegos didácticos para niños ciegos y videntes""Sistema Constanz"L'ocupació laboral dels cecs a l'Estat espanyol està pràcticament equiparada a la de les persones amb visió, entrevista amb Pedro ZuritaONCE (Organización Nacional de Cegos de España)Prevención da cegueiraDescrición de deficiencias visuais (Disc@pnet)Braillín, un boneco atractivo para calquera neno, con ou sen discapacidade, que permite familiarizarse co sistema de escritura e lectura brailleAxudas Técnicas36838ID00897494007150-90057129528256DOID:1432HP:0000618D001766C10.597.751.941.162C97109C0155020