HTACCESS redirect for multiple Vue router applications depending on URL











up vote
2
down vote

favorite












Running three vue.js applications with vue-router on apache sever.



The HTACCESS redirects all non existing paths to /folder1/index.html. Now I want to include a redirect when the user accesses /folder2/success > /folder2/index.html instead of folder1/index.html



My current HTACCESS file looks as follows, however it isn't working it still redirects to folder1.



<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /folder1/index.html [L]
RewriteRule /folder2/success /folder2/index.html [L]
</IfModule>


Really stuck on this any suggestions would be greatly appreciated!










share|improve this question


























    up vote
    2
    down vote

    favorite












    Running three vue.js applications with vue-router on apache sever.



    The HTACCESS redirects all non existing paths to /folder1/index.html. Now I want to include a redirect when the user accesses /folder2/success > /folder2/index.html instead of folder1/index.html



    My current HTACCESS file looks as follows, however it isn't working it still redirects to folder1.



    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.html$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /folder1/index.html [L]
    RewriteRule /folder2/success /folder2/index.html [L]
    </IfModule>


    Really stuck on this any suggestions would be greatly appreciated!










    share|improve this question
























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      Running three vue.js applications with vue-router on apache sever.



      The HTACCESS redirects all non existing paths to /folder1/index.html. Now I want to include a redirect when the user accesses /folder2/success > /folder2/index.html instead of folder1/index.html



      My current HTACCESS file looks as follows, however it isn't working it still redirects to folder1.



      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index.html$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /folder1/index.html [L]
      RewriteRule /folder2/success /folder2/index.html [L]
      </IfModule>


      Really stuck on this any suggestions would be greatly appreciated!










      share|improve this question













      Running three vue.js applications with vue-router on apache sever.



      The HTACCESS redirects all non existing paths to /folder1/index.html. Now I want to include a redirect when the user accesses /folder2/success > /folder2/index.html instead of folder1/index.html



      My current HTACCESS file looks as follows, however it isn't working it still redirects to folder1.



      <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteBase /
      RewriteRule ^index.html$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /folder1/index.html [L]
      RewriteRule /folder2/success /folder2/index.html [L]
      </IfModule>


      Really stuck on this any suggestions would be greatly appreciated!







      .htaccess vue.js






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 at 10:43









      Benjamin Waye

      111




      111
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Rules are executed in the order they are written. Since /folder/success does not exist as a file or directory, it is rewritten to /folder/index.html, which does not match your rule for /folder2/success.



          Furthermore, since this is in a .htaccess file, it is in the context of that folder. The prefix of that folder is always removed from the part of the url that is matched, which means that the part that is matched never begins with a slash. You should be matching against folder2/success instead.



          Your .htaccess file would look something like this:



          <IfModule mod_rewrite.c>
          RewriteEngine On
          RewriteBase /
          RewriteRule ^index.html$ - [L]

          RewriteRule ^folder2/success /folder2/index.html [L]

          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule . /folder1/index.html [L]
          </IfModule>





          share|improve this answer





















          • Thanks! This solved it, I thought it might have been executing in the order it was written. What does the "^" do?
            – Benjamin Waye
            Nov 22 at 14:33










          • The first argument of RewriteRule is a regex that is used to test against the url. ^ matches against the beginning of the string. Using ^ there guards against the rule matching against example.com/random/folder2/success for example.
            – Sumurai8
            Nov 22 at 16:16











          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',
          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%2f53429146%2fhtaccess-redirect-for-multiple-vue-router-applications-depending-on-url%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








          up vote
          0
          down vote













          Rules are executed in the order they are written. Since /folder/success does not exist as a file or directory, it is rewritten to /folder/index.html, which does not match your rule for /folder2/success.



          Furthermore, since this is in a .htaccess file, it is in the context of that folder. The prefix of that folder is always removed from the part of the url that is matched, which means that the part that is matched never begins with a slash. You should be matching against folder2/success instead.



          Your .htaccess file would look something like this:



          <IfModule mod_rewrite.c>
          RewriteEngine On
          RewriteBase /
          RewriteRule ^index.html$ - [L]

          RewriteRule ^folder2/success /folder2/index.html [L]

          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule . /folder1/index.html [L]
          </IfModule>





          share|improve this answer





















          • Thanks! This solved it, I thought it might have been executing in the order it was written. What does the "^" do?
            – Benjamin Waye
            Nov 22 at 14:33










          • The first argument of RewriteRule is a regex that is used to test against the url. ^ matches against the beginning of the string. Using ^ there guards against the rule matching against example.com/random/folder2/success for example.
            – Sumurai8
            Nov 22 at 16:16















          up vote
          0
          down vote













          Rules are executed in the order they are written. Since /folder/success does not exist as a file or directory, it is rewritten to /folder/index.html, which does not match your rule for /folder2/success.



          Furthermore, since this is in a .htaccess file, it is in the context of that folder. The prefix of that folder is always removed from the part of the url that is matched, which means that the part that is matched never begins with a slash. You should be matching against folder2/success instead.



          Your .htaccess file would look something like this:



          <IfModule mod_rewrite.c>
          RewriteEngine On
          RewriteBase /
          RewriteRule ^index.html$ - [L]

          RewriteRule ^folder2/success /folder2/index.html [L]

          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule . /folder1/index.html [L]
          </IfModule>





          share|improve this answer





















          • Thanks! This solved it, I thought it might have been executing in the order it was written. What does the "^" do?
            – Benjamin Waye
            Nov 22 at 14:33










          • The first argument of RewriteRule is a regex that is used to test against the url. ^ matches against the beginning of the string. Using ^ there guards against the rule matching against example.com/random/folder2/success for example.
            – Sumurai8
            Nov 22 at 16:16













          up vote
          0
          down vote










          up vote
          0
          down vote









          Rules are executed in the order they are written. Since /folder/success does not exist as a file or directory, it is rewritten to /folder/index.html, which does not match your rule for /folder2/success.



          Furthermore, since this is in a .htaccess file, it is in the context of that folder. The prefix of that folder is always removed from the part of the url that is matched, which means that the part that is matched never begins with a slash. You should be matching against folder2/success instead.



          Your .htaccess file would look something like this:



          <IfModule mod_rewrite.c>
          RewriteEngine On
          RewriteBase /
          RewriteRule ^index.html$ - [L]

          RewriteRule ^folder2/success /folder2/index.html [L]

          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule . /folder1/index.html [L]
          </IfModule>





          share|improve this answer












          Rules are executed in the order they are written. Since /folder/success does not exist as a file or directory, it is rewritten to /folder/index.html, which does not match your rule for /folder2/success.



          Furthermore, since this is in a .htaccess file, it is in the context of that folder. The prefix of that folder is always removed from the part of the url that is matched, which means that the part that is matched never begins with a slash. You should be matching against folder2/success instead.



          Your .htaccess file would look something like this:



          <IfModule mod_rewrite.c>
          RewriteEngine On
          RewriteBase /
          RewriteRule ^index.html$ - [L]

          RewriteRule ^folder2/success /folder2/index.html [L]

          RewriteCond %{REQUEST_FILENAME} !-f
          RewriteCond %{REQUEST_FILENAME} !-d
          RewriteRule . /folder1/index.html [L]
          </IfModule>






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 22 at 11:06









          Sumurai8

          12.7k83160




          12.7k83160












          • Thanks! This solved it, I thought it might have been executing in the order it was written. What does the "^" do?
            – Benjamin Waye
            Nov 22 at 14:33










          • The first argument of RewriteRule is a regex that is used to test against the url. ^ matches against the beginning of the string. Using ^ there guards against the rule matching against example.com/random/folder2/success for example.
            – Sumurai8
            Nov 22 at 16:16


















          • Thanks! This solved it, I thought it might have been executing in the order it was written. What does the "^" do?
            – Benjamin Waye
            Nov 22 at 14:33










          • The first argument of RewriteRule is a regex that is used to test against the url. ^ matches against the beginning of the string. Using ^ there guards against the rule matching against example.com/random/folder2/success for example.
            – Sumurai8
            Nov 22 at 16:16
















          Thanks! This solved it, I thought it might have been executing in the order it was written. What does the "^" do?
          – Benjamin Waye
          Nov 22 at 14:33




          Thanks! This solved it, I thought it might have been executing in the order it was written. What does the "^" do?
          – Benjamin Waye
          Nov 22 at 14:33












          The first argument of RewriteRule is a regex that is used to test against the url. ^ matches against the beginning of the string. Using ^ there guards against the rule matching against example.com/random/folder2/success for example.
          – Sumurai8
          Nov 22 at 16:16




          The first argument of RewriteRule is a regex that is used to test against the url. ^ matches against the beginning of the string. Using ^ there guards against the rule matching against example.com/random/folder2/success for example.
          – Sumurai8
          Nov 22 at 16:16


















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f53429146%2fhtaccess-redirect-for-multiple-vue-router-applications-depending-on-url%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

          Trompette piccolo

          Slow SSRS Report in dynamic grouping and multiple parameters

          Simon Yates (cyclisme)