React Router - Ignore / Redirect to subfolder












1















Is it possible to ignore a specific URL in the react router?



I have an app for a service desk app in a subdir which I can not reach, once I have entered the react app.



<Route
exact
path="/"
component={ViewHome}
/>

<Route
path="/about"
component={ViewAbout}
/>

<Route
path="/help"
// Ignore the React App and forward this request to the server.
/>


As Marvin stated in his answer, this could be a server config problem. Here is the content of the .htaccess rewrite.



RewriteEngine On
RewriteBase /

RewriteRule ^(help)($|/) - [L]

RewriteRule ^index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]


Any ideas?










share|improve this question





























    1















    Is it possible to ignore a specific URL in the react router?



    I have an app for a service desk app in a subdir which I can not reach, once I have entered the react app.



    <Route
    exact
    path="/"
    component={ViewHome}
    />

    <Route
    path="/about"
    component={ViewAbout}
    />

    <Route
    path="/help"
    // Ignore the React App and forward this request to the server.
    />


    As Marvin stated in his answer, this could be a server config problem. Here is the content of the .htaccess rewrite.



    RewriteEngine On
    RewriteBase /

    RewriteRule ^(help)($|/) - [L]

    RewriteRule ^index.html$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.html [L]


    Any ideas?










    share|improve this question



























      1












      1








      1








      Is it possible to ignore a specific URL in the react router?



      I have an app for a service desk app in a subdir which I can not reach, once I have entered the react app.



      <Route
      exact
      path="/"
      component={ViewHome}
      />

      <Route
      path="/about"
      component={ViewAbout}
      />

      <Route
      path="/help"
      // Ignore the React App and forward this request to the server.
      />


      As Marvin stated in his answer, this could be a server config problem. Here is the content of the .htaccess rewrite.



      RewriteEngine On
      RewriteBase /

      RewriteRule ^(help)($|/) - [L]

      RewriteRule ^index.html$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.html [L]


      Any ideas?










      share|improve this question
















      Is it possible to ignore a specific URL in the react router?



      I have an app for a service desk app in a subdir which I can not reach, once I have entered the react app.



      <Route
      exact
      path="/"
      component={ViewHome}
      />

      <Route
      path="/about"
      component={ViewAbout}
      />

      <Route
      path="/help"
      // Ignore the React App and forward this request to the server.
      />


      As Marvin stated in his answer, this could be a server config problem. Here is the content of the .htaccess rewrite.



      RewriteEngine On
      RewriteBase /

      RewriteRule ^(help)($|/) - [L]

      RewriteRule ^index.html$ - [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.html [L]


      Any ideas?







      reactjs .htaccess react-router react-router-dom






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 19 '18 at 13:14







      Marvin

















      asked Nov 19 '18 at 12:41









      MarvinMarvin

      90118




      90118
























          1 Answer
          1






          active

          oldest

          votes


















          1














          I don't know if I understand your question, but this sounds like a server configuration issue.



          For example, I use Nginx on my server to configure the router.
          The usual behavior of your browser is to search for a subdirectory when you do /something.



          But if you configure it in a way that your servers keeps looking at your index file it should be fine.



          What works for me in my Nginx config:



          location / {
          try_files $uri /index.html;
          }





          share|improve this answer
























          • You seem to be right. Since Apache is running on my machine, I have to search the htaccess. I'll update the question.

            – Marvin
            Nov 19 '18 at 13: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%2f53374881%2freact-router-ignore-redirect-to-subfolder%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









          1














          I don't know if I understand your question, but this sounds like a server configuration issue.



          For example, I use Nginx on my server to configure the router.
          The usual behavior of your browser is to search for a subdirectory when you do /something.



          But if you configure it in a way that your servers keeps looking at your index file it should be fine.



          What works for me in my Nginx config:



          location / {
          try_files $uri /index.html;
          }





          share|improve this answer
























          • You seem to be right. Since Apache is running on my machine, I have to search the htaccess. I'll update the question.

            – Marvin
            Nov 19 '18 at 13:11
















          1














          I don't know if I understand your question, but this sounds like a server configuration issue.



          For example, I use Nginx on my server to configure the router.
          The usual behavior of your browser is to search for a subdirectory when you do /something.



          But if you configure it in a way that your servers keeps looking at your index file it should be fine.



          What works for me in my Nginx config:



          location / {
          try_files $uri /index.html;
          }





          share|improve this answer
























          • You seem to be right. Since Apache is running on my machine, I have to search the htaccess. I'll update the question.

            – Marvin
            Nov 19 '18 at 13:11














          1












          1








          1







          I don't know if I understand your question, but this sounds like a server configuration issue.



          For example, I use Nginx on my server to configure the router.
          The usual behavior of your browser is to search for a subdirectory when you do /something.



          But if you configure it in a way that your servers keeps looking at your index file it should be fine.



          What works for me in my Nginx config:



          location / {
          try_files $uri /index.html;
          }





          share|improve this answer













          I don't know if I understand your question, but this sounds like a server configuration issue.



          For example, I use Nginx on my server to configure the router.
          The usual behavior of your browser is to search for a subdirectory when you do /something.



          But if you configure it in a way that your servers keeps looking at your index file it should be fine.



          What works for me in my Nginx config:



          location / {
          try_files $uri /index.html;
          }






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 19 '18 at 12:55









          MarvinVKMarvinVK

          1,388912




          1,388912













          • You seem to be right. Since Apache is running on my machine, I have to search the htaccess. I'll update the question.

            – Marvin
            Nov 19 '18 at 13:11



















          • You seem to be right. Since Apache is running on my machine, I have to search the htaccess. I'll update the question.

            – Marvin
            Nov 19 '18 at 13:11

















          You seem to be right. Since Apache is running on my machine, I have to search the htaccess. I'll update the question.

          – Marvin
          Nov 19 '18 at 13:11





          You seem to be right. Since Apache is running on my machine, I have to search the htaccess. I'll update the question.

          – Marvin
          Nov 19 '18 at 13: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%2f53374881%2freact-router-ignore-redirect-to-subfolder%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

          How to change which sound is reproduced for terminal bell?

          Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

          Can I use Tabulator js library in my java Spring + Thymeleaf project?