301 Redirect from non-existent subdomain to subfolder ( closed wordpress multi-site )





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















About to change a wordpress multi-site with 100+ locations to a standard wordpress site and I'd like to redirect the old closed subdomains to the new specific subfolders relating to those locations.



Because wordpress creates the subdomains dynamically I'm trying to work out if there is a easy way to 301 redirect from the now non-existent subdomains to the new subfolders via htaccess...



https://example1.domain.com.au > https://www.domain.com.au/office-locations/example1



https://example2.domain.com.au > https://www.domain.com.au/office-locations/example2



I'd appreciate any help I've tried a few simple redirect lines like the following with no luck just yet. And i'm not even sure if the .htaccess file in the root folder is best or the one in the main domains public html folder.



RewriteEngine On
RewriteCond %{HTTP_HOST} ^example1.domain.com.au$ [NC]
RewriteRule (.*) http://www.domain.com.au/locations/example1 [R=301,L]
RewriteCond %{HTTP_HOST} ^example2.domain.com.au$ [NC]
RewriteRule (.*) http://www.domain.com.au/locations/example2 [R=301,L]


Cheers and hope this makes sense










share|improve this question





























    0















    About to change a wordpress multi-site with 100+ locations to a standard wordpress site and I'd like to redirect the old closed subdomains to the new specific subfolders relating to those locations.



    Because wordpress creates the subdomains dynamically I'm trying to work out if there is a easy way to 301 redirect from the now non-existent subdomains to the new subfolders via htaccess...



    https://example1.domain.com.au > https://www.domain.com.au/office-locations/example1



    https://example2.domain.com.au > https://www.domain.com.au/office-locations/example2



    I'd appreciate any help I've tried a few simple redirect lines like the following with no luck just yet. And i'm not even sure if the .htaccess file in the root folder is best or the one in the main domains public html folder.



    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^example1.domain.com.au$ [NC]
    RewriteRule (.*) http://www.domain.com.au/locations/example1 [R=301,L]
    RewriteCond %{HTTP_HOST} ^example2.domain.com.au$ [NC]
    RewriteRule (.*) http://www.domain.com.au/locations/example2 [R=301,L]


    Cheers and hope this makes sense










    share|improve this question

























      0












      0








      0








      About to change a wordpress multi-site with 100+ locations to a standard wordpress site and I'd like to redirect the old closed subdomains to the new specific subfolders relating to those locations.



      Because wordpress creates the subdomains dynamically I'm trying to work out if there is a easy way to 301 redirect from the now non-existent subdomains to the new subfolders via htaccess...



      https://example1.domain.com.au > https://www.domain.com.au/office-locations/example1



      https://example2.domain.com.au > https://www.domain.com.au/office-locations/example2



      I'd appreciate any help I've tried a few simple redirect lines like the following with no luck just yet. And i'm not even sure if the .htaccess file in the root folder is best or the one in the main domains public html folder.



      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^example1.domain.com.au$ [NC]
      RewriteRule (.*) http://www.domain.com.au/locations/example1 [R=301,L]
      RewriteCond %{HTTP_HOST} ^example2.domain.com.au$ [NC]
      RewriteRule (.*) http://www.domain.com.au/locations/example2 [R=301,L]


      Cheers and hope this makes sense










      share|improve this question














      About to change a wordpress multi-site with 100+ locations to a standard wordpress site and I'd like to redirect the old closed subdomains to the new specific subfolders relating to those locations.



      Because wordpress creates the subdomains dynamically I'm trying to work out if there is a easy way to 301 redirect from the now non-existent subdomains to the new subfolders via htaccess...



      https://example1.domain.com.au > https://www.domain.com.au/office-locations/example1



      https://example2.domain.com.au > https://www.domain.com.au/office-locations/example2



      I'd appreciate any help I've tried a few simple redirect lines like the following with no luck just yet. And i'm not even sure if the .htaccess file in the root folder is best or the one in the main domains public html folder.



      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^example1.domain.com.au$ [NC]
      RewriteRule (.*) http://www.domain.com.au/locations/example1 [R=301,L]
      RewriteCond %{HTTP_HOST} ^example2.domain.com.au$ [NC]
      RewriteRule (.*) http://www.domain.com.au/locations/example2 [R=301,L]


      Cheers and hope this makes sense







      wordpress apache .htaccess redirect multisite






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 3 at 7:09









      user2562620user2562620

      51




      51
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Try this:



          RewriteEngine On
          RewriteCond %{HTTP_HOST} ^example1.domain.com.au$
          RewriteRule ^(.*)$ http://www.domain.com.au/example1/$1 [R=301,L]





          share|improve this answer


























          • Thank you for this... I'd created some subdomains on the testing site and was prepared to do it all manual. On creating the new site I tested this out before i got to work and seemed to work just fine... Cheers buddy I owe you an ice cream lol

            – user2562620
            Feb 5 at 4:11












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54017794%2f301-redirect-from-non-existent-subdomain-to-subfolder-closed-wordpress-multi-s%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          Try this:



          RewriteEngine On
          RewriteCond %{HTTP_HOST} ^example1.domain.com.au$
          RewriteRule ^(.*)$ http://www.domain.com.au/example1/$1 [R=301,L]





          share|improve this answer


























          • Thank you for this... I'd created some subdomains on the testing site and was prepared to do it all manual. On creating the new site I tested this out before i got to work and seemed to work just fine... Cheers buddy I owe you an ice cream lol

            – user2562620
            Feb 5 at 4:11
















          0














          Try this:



          RewriteEngine On
          RewriteCond %{HTTP_HOST} ^example1.domain.com.au$
          RewriteRule ^(.*)$ http://www.domain.com.au/example1/$1 [R=301,L]





          share|improve this answer


























          • Thank you for this... I'd created some subdomains on the testing site and was prepared to do it all manual. On creating the new site I tested this out before i got to work and seemed to work just fine... Cheers buddy I owe you an ice cream lol

            – user2562620
            Feb 5 at 4:11














          0












          0








          0







          Try this:



          RewriteEngine On
          RewriteCond %{HTTP_HOST} ^example1.domain.com.au$
          RewriteRule ^(.*)$ http://www.domain.com.au/example1/$1 [R=301,L]





          share|improve this answer















          Try this:



          RewriteEngine On
          RewriteCond %{HTTP_HOST} ^example1.domain.com.au$
          RewriteRule ^(.*)$ http://www.domain.com.au/example1/$1 [R=301,L]






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 3 at 7:52

























          answered Jan 3 at 7:40









          Muhammad BilalMuhammad Bilal

          1,80311222




          1,80311222













          • Thank you for this... I'd created some subdomains on the testing site and was prepared to do it all manual. On creating the new site I tested this out before i got to work and seemed to work just fine... Cheers buddy I owe you an ice cream lol

            – user2562620
            Feb 5 at 4:11



















          • Thank you for this... I'd created some subdomains on the testing site and was prepared to do it all manual. On creating the new site I tested this out before i got to work and seemed to work just fine... Cheers buddy I owe you an ice cream lol

            – user2562620
            Feb 5 at 4:11

















          Thank you for this... I'd created some subdomains on the testing site and was prepared to do it all manual. On creating the new site I tested this out before i got to work and seemed to work just fine... Cheers buddy I owe you an ice cream lol

          – user2562620
          Feb 5 at 4:11





          Thank you for this... I'd created some subdomains on the testing site and was prepared to do it all manual. On creating the new site I tested this out before i got to work and seemed to work just fine... Cheers buddy I owe you an ice cream lol

          – user2562620
          Feb 5 at 4:11




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • 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%2fstackoverflow.com%2fquestions%2f54017794%2f301-redirect-from-non-existent-subdomain-to-subfolder-closed-wordpress-multi-s%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

          'app-layout' is not a known element: how to share Component with different Modules

          android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

          WPF add header to Image with URL pettitions [duplicate]