React Router - Ignore / Redirect to subfolder
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
add a comment |
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
add a comment |
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
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
reactjs .htaccess react-router react-router-dom
edited Nov 19 '18 at 13:14
Marvin
asked Nov 19 '18 at 12:41
MarvinMarvin
90118
90118
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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;
}
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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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;
}
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
add a comment |
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;
}
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
add a comment |
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;
}
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;
}
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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