How to switch between two websites in a domain name?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
1
down vote

favorite












I have a server running Ubuntu 16.04. When you type the domain name, for example, www.mydomainname.com it leads you to a board1. And when you type an ip address like 189.11.22.1:40443 (or domain name with the port) it leads you to another, board2.



I want to switch between these two boards: put the first board1 on ip address and the second one on the domain name.



How can I do that?



P.s. I am using nginx for configuration.










share|improve this question



























    up vote
    1
    down vote

    favorite












    I have a server running Ubuntu 16.04. When you type the domain name, for example, www.mydomainname.com it leads you to a board1. And when you type an ip address like 189.11.22.1:40443 (or domain name with the port) it leads you to another, board2.



    I want to switch between these two boards: put the first board1 on ip address and the second one on the domain name.



    How can I do that?



    P.s. I am using nginx for configuration.










    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I have a server running Ubuntu 16.04. When you type the domain name, for example, www.mydomainname.com it leads you to a board1. And when you type an ip address like 189.11.22.1:40443 (or domain name with the port) it leads you to another, board2.



      I want to switch between these two boards: put the first board1 on ip address and the second one on the domain name.



      How can I do that?



      P.s. I am using nginx for configuration.










      share|improve this question















      I have a server running Ubuntu 16.04. When you type the domain name, for example, www.mydomainname.com it leads you to a board1. And when you type an ip address like 189.11.22.1:40443 (or domain name with the port) it leads you to another, board2.



      I want to switch between these two boards: put the first board1 on ip address and the second one on the domain name.



      How can I do that?



      P.s. I am using nginx for configuration.







      16.04 server






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 23 at 17:21









      wjandrea

      7,19342255




      7,19342255










      asked Mar 23 at 14:33









      Ys3

      134




      134




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          With apache2 <virtualhost> directive, you can set servername, that corresponds to the domain name. So you point 2 names to same ip, and serve those from 2 virtualhosts, that are placed in different directories.



          You can also specify ports to listen on virtualhost directive.



          For example:



          </VirtualHost>
          </IfModule>
          <IfModule mod_ssl.c>
          <VirtualHost *:80>
          ServerName pasiz.net
          ServerAlias www.pasiz.net
          DocumentRoot /var/www/www.pasiz.net/htdocs
          ServerAdmin pasiz@pasiz.net
          ErrorLog /var/www/www.pasiz.net/log/error.log
          CustomLog /var/www/www.pasiz.net/log/access.log combined
          RewriteEngine on
          </VirtualHost>
          </IfModule>


          "Virtualhost" alias Server Block for nginx:



          server 
          listen 80;
          listen [::]:80;

          root /var/www/example.com/html;
          index index.html index.htm index.nginx-debian.html;

          server_name example.com www.example.com;

          location /
          try_files $uri $uri/ =404;




          https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/






          share|improve this answer






















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "89"
            ;
            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',
            convertImagesToLinks: true,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1018572%2fhow-to-switch-between-two-websites-in-a-domain-name%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            With apache2 <virtualhost> directive, you can set servername, that corresponds to the domain name. So you point 2 names to same ip, and serve those from 2 virtualhosts, that are placed in different directories.



            You can also specify ports to listen on virtualhost directive.



            For example:



            </VirtualHost>
            </IfModule>
            <IfModule mod_ssl.c>
            <VirtualHost *:80>
            ServerName pasiz.net
            ServerAlias www.pasiz.net
            DocumentRoot /var/www/www.pasiz.net/htdocs
            ServerAdmin pasiz@pasiz.net
            ErrorLog /var/www/www.pasiz.net/log/error.log
            CustomLog /var/www/www.pasiz.net/log/access.log combined
            RewriteEngine on
            </VirtualHost>
            </IfModule>


            "Virtualhost" alias Server Block for nginx:



            server 
            listen 80;
            listen [::]:80;

            root /var/www/example.com/html;
            index index.html index.htm index.nginx-debian.html;

            server_name example.com www.example.com;

            location /
            try_files $uri $uri/ =404;




            https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/






            share|improve this answer


























              up vote
              0
              down vote



              accepted










              With apache2 <virtualhost> directive, you can set servername, that corresponds to the domain name. So you point 2 names to same ip, and serve those from 2 virtualhosts, that are placed in different directories.



              You can also specify ports to listen on virtualhost directive.



              For example:



              </VirtualHost>
              </IfModule>
              <IfModule mod_ssl.c>
              <VirtualHost *:80>
              ServerName pasiz.net
              ServerAlias www.pasiz.net
              DocumentRoot /var/www/www.pasiz.net/htdocs
              ServerAdmin pasiz@pasiz.net
              ErrorLog /var/www/www.pasiz.net/log/error.log
              CustomLog /var/www/www.pasiz.net/log/access.log combined
              RewriteEngine on
              </VirtualHost>
              </IfModule>


              "Virtualhost" alias Server Block for nginx:



              server 
              listen 80;
              listen [::]:80;

              root /var/www/example.com/html;
              index index.html index.htm index.nginx-debian.html;

              server_name example.com www.example.com;

              location /
              try_files $uri $uri/ =404;




              https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/






              share|improve this answer
























                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                With apache2 <virtualhost> directive, you can set servername, that corresponds to the domain name. So you point 2 names to same ip, and serve those from 2 virtualhosts, that are placed in different directories.



                You can also specify ports to listen on virtualhost directive.



                For example:



                </VirtualHost>
                </IfModule>
                <IfModule mod_ssl.c>
                <VirtualHost *:80>
                ServerName pasiz.net
                ServerAlias www.pasiz.net
                DocumentRoot /var/www/www.pasiz.net/htdocs
                ServerAdmin pasiz@pasiz.net
                ErrorLog /var/www/www.pasiz.net/log/error.log
                CustomLog /var/www/www.pasiz.net/log/access.log combined
                RewriteEngine on
                </VirtualHost>
                </IfModule>


                "Virtualhost" alias Server Block for nginx:



                server 
                listen 80;
                listen [::]:80;

                root /var/www/example.com/html;
                index index.html index.htm index.nginx-debian.html;

                server_name example.com www.example.com;

                location /
                try_files $uri $uri/ =404;




                https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/






                share|improve this answer














                With apache2 <virtualhost> directive, you can set servername, that corresponds to the domain name. So you point 2 names to same ip, and serve those from 2 virtualhosts, that are placed in different directories.



                You can also specify ports to listen on virtualhost directive.



                For example:



                </VirtualHost>
                </IfModule>
                <IfModule mod_ssl.c>
                <VirtualHost *:80>
                ServerName pasiz.net
                ServerAlias www.pasiz.net
                DocumentRoot /var/www/www.pasiz.net/htdocs
                ServerAdmin pasiz@pasiz.net
                ErrorLog /var/www/www.pasiz.net/log/error.log
                CustomLog /var/www/www.pasiz.net/log/access.log combined
                RewriteEngine on
                </VirtualHost>
                </IfModule>


                "Virtualhost" alias Server Block for nginx:



                server 
                listen 80;
                listen [::]:80;

                root /var/www/example.com/html;
                index index.html index.htm index.nginx-debian.html;

                server_name example.com www.example.com;

                location /
                try_files $uri $uri/ =404;




                https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 23 at 18:33

























                answered Mar 23 at 17:20









                Pasi Suominen

                44526




                44526



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1018572%2fhow-to-switch-between-two-websites-in-a-domain-name%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    Which professions warranted travel in Medieval times?

                    Trouble downloading packages list due to a “Hash sum mismatch” error

                    How do so many people here on Academia.SE, and in general, afford lavish higher education programs?