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!
.htaccess vue.js
add a comment |
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!
.htaccess vue.js
add a comment |
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!
.htaccess vue.js
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
.htaccess vue.js
asked Nov 22 at 10:43
Benjamin Waye
111
111
add a comment |
add a comment |
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>
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 ofRewriteRule
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 againstexample.com/random/folder2/success
for example.
– Sumurai8
Nov 22 at 16:16
add a comment |
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>
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 ofRewriteRule
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 againstexample.com/random/folder2/success
for example.
– Sumurai8
Nov 22 at 16:16
add a comment |
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>
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 ofRewriteRule
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 againstexample.com/random/folder2/success
for example.
– Sumurai8
Nov 22 at 16:16
add a comment |
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>
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>
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 ofRewriteRule
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 againstexample.com/random/folder2/success
for example.
– Sumurai8
Nov 22 at 16:16
add a comment |
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 ofRewriteRule
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 againstexample.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
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.
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.
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%2f53429146%2fhtaccess-redirect-for-multiple-vue-router-applications-depending-on-url%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