Can't figure out a htaccess ruleWhy does this mod_rewrite rule 'not-match'? (big rewrite log included)Can...
Why don't programs completely uninstall (remove all their files) when I remove them?
Are one-line email responses considered disrespectful?
Taking an academic pseudonym?
Is it possible to narrate a novel in a faux-historical style without alienating the reader?
How can guns be countered by melee combat without raw-ability or exceptional explanations?
Including proofs of known theorems in master's thesis
What is formjacking?
How can I prep for the Curse of Strahd adventure effectively?
What does "south of due west" mean?
Does an enchantment ability that gives -1/-1 to opponent creatures resolve before other abilities can be used on a 1/1 entering the battlefield
Is the Maximum Use License for Everybody (MULE) a FOSS license?
How can I give a Ranger advantage on a check due to Favored Enemy without spoiling the story for the player?
Identical projects by students at two different colleges: still plagiarism?
Converting numbers to words - Python
How do I make my single-minded character more interested in the main story?
Why is Shelob considered evil?
Buying a "Used" Router
Can someone explain European graduate programs in STEM fields?
Missing a connection and don't have money to book next flight
How to transport 10,000 terrestrial trolls across ocean fast?
Plotting Laguerre Gaussian beam intensity in transverse and line profile via center?
When does a person lose diplomatic status?
How can changes in personality/values of a person who turned into a vampire be explained?
Crack the bank account's password!
Can't figure out a htaccess rule
Why does this mod_rewrite rule 'not-match'? (big rewrite log included)Can mod_rewrite Conditions/Rules be executed in random order?Can't set up rewrite rule for different folder in htaccessCan I redirect to the newest file in directory using .htaccess?Mod_rewite - do these rewrite rules work?Difference b/w .htaccess and example.com.confrewrite rule does not rewrite url as expectedA specific issue with Apache 2.2 URL rewritingWhat does this wordpress .htaccess rule do?Why doesn't this .htaccess file redirect properly?
I have this in my htaccess but can't figure out what its for.
Because of the nature of rule, searching doesn't help either.
RewriteCond %{REQUEST_URI} !(/$|.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301]
Can anyone please explain what its for?
linux apache-2.2 apache-2.4 .htaccess mod-rewrite
New contributor
add a comment |
I have this in my htaccess but can't figure out what its for.
Because of the nature of rule, searching doesn't help either.
RewriteCond %{REQUEST_URI} !(/$|.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301]
Can anyone please explain what its for?
linux apache-2.2 apache-2.4 .htaccess mod-rewrite
New contributor
add a comment |
I have this in my htaccess but can't figure out what its for.
Because of the nature of rule, searching doesn't help either.
RewriteCond %{REQUEST_URI} !(/$|.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301]
Can anyone please explain what its for?
linux apache-2.2 apache-2.4 .htaccess mod-rewrite
New contributor
I have this in my htaccess but can't figure out what its for.
Because of the nature of rule, searching doesn't help either.
RewriteCond %{REQUEST_URI} !(/$|.)
RewriteRule (.*) %{REQUEST_URI}/ [R=301]
Can anyone please explain what its for?
linux apache-2.2 apache-2.4 .htaccess mod-rewrite
linux apache-2.2 apache-2.4 .htaccess mod-rewrite
New contributor
New contributor
New contributor
asked 1 hour ago
Richard1984Richard1984
83
83
New contributor
New contributor
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
All this rule does is to add a trailing /
to your URLS if there is none and if there is no .
in the URI, so https://example.org/test
will be redirected to https://example.org/test/
, but https://example.org/test.html
will not be rewritten to https://example.org/test.html/
## Do the following if the URI does not end with `/` or does not contain an `.`:
## the . is relevant for file names like test.html, which should n
RewriteCond %{REQUEST_URI} !(/$|.)
## Redirect it to the original URI with an added `/` and mark this as permanent:
RewriteRule (.*) %{REQUEST_URI}/ [R=301]
@MrWhite: You are right of course. Silly me ...
– Sven♦
28 mins ago
As the accepted answer you could add the edge-case to your answer (see my answer).
– Joffrey
22 mins ago
add a comment |
Without validating, but using my experience in Apache rewriting, this configuration seems to:
- Match on the 'path' part of the URI (not the server, port, or query parameters), for example '/my/location/file.html'.
- Match if this part does not end on a '/' (forward-slash) character, -or- does not include a '.' (dot) character.
- Use the full path part of the URI and append a forward-slash to it.
- Send a HTTP 301 (permanent) redirect to direct the browser to this new URI.
This will result in the following test cases
/ -> /
/test -> /test/
/my/resource -> /my/resource/
/my/resource.type -> /my/resource.type
/edge.case/resource -> /edge.case/resource
So I think the rule has a purpose of adding slashes to resources that do not seem to be a file, but it seems to have an edge-case.
If not adding a slash to a resource with '.' (dot) character in the non-file part of the path the regular expression should be changed to:
# match paths which do not end with a slash, or do not resemble a file with an extension
RewriteCond %{REQUEST_URI} !(/$|.[^/]*)
# redirect permanently to the same uri with a slash
RewriteRule (.*) %{REQUEST_URI}/ [R=301]
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "2"
};
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
});
}
});
Richard1984 is a new contributor. Be nice, and check out our Code of Conduct.
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%2fserverfault.com%2fquestions%2f955402%2fcant-figure-out-a-htaccess-rule%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
All this rule does is to add a trailing /
to your URLS if there is none and if there is no .
in the URI, so https://example.org/test
will be redirected to https://example.org/test/
, but https://example.org/test.html
will not be rewritten to https://example.org/test.html/
## Do the following if the URI does not end with `/` or does not contain an `.`:
## the . is relevant for file names like test.html, which should n
RewriteCond %{REQUEST_URI} !(/$|.)
## Redirect it to the original URI with an added `/` and mark this as permanent:
RewriteRule (.*) %{REQUEST_URI}/ [R=301]
@MrWhite: You are right of course. Silly me ...
– Sven♦
28 mins ago
As the accepted answer you could add the edge-case to your answer (see my answer).
– Joffrey
22 mins ago
add a comment |
All this rule does is to add a trailing /
to your URLS if there is none and if there is no .
in the URI, so https://example.org/test
will be redirected to https://example.org/test/
, but https://example.org/test.html
will not be rewritten to https://example.org/test.html/
## Do the following if the URI does not end with `/` or does not contain an `.`:
## the . is relevant for file names like test.html, which should n
RewriteCond %{REQUEST_URI} !(/$|.)
## Redirect it to the original URI with an added `/` and mark this as permanent:
RewriteRule (.*) %{REQUEST_URI}/ [R=301]
@MrWhite: You are right of course. Silly me ...
– Sven♦
28 mins ago
As the accepted answer you could add the edge-case to your answer (see my answer).
– Joffrey
22 mins ago
add a comment |
All this rule does is to add a trailing /
to your URLS if there is none and if there is no .
in the URI, so https://example.org/test
will be redirected to https://example.org/test/
, but https://example.org/test.html
will not be rewritten to https://example.org/test.html/
## Do the following if the URI does not end with `/` or does not contain an `.`:
## the . is relevant for file names like test.html, which should n
RewriteCond %{REQUEST_URI} !(/$|.)
## Redirect it to the original URI with an added `/` and mark this as permanent:
RewriteRule (.*) %{REQUEST_URI}/ [R=301]
All this rule does is to add a trailing /
to your URLS if there is none and if there is no .
in the URI, so https://example.org/test
will be redirected to https://example.org/test/
, but https://example.org/test.html
will not be rewritten to https://example.org/test.html/
## Do the following if the URI does not end with `/` or does not contain an `.`:
## the . is relevant for file names like test.html, which should n
RewriteCond %{REQUEST_URI} !(/$|.)
## Redirect it to the original URI with an added `/` and mark this as permanent:
RewriteRule (.*) %{REQUEST_URI}/ [R=301]
edited 26 mins ago
answered 30 mins ago
Sven♦Sven
86.8k10144198
86.8k10144198
@MrWhite: You are right of course. Silly me ...
– Sven♦
28 mins ago
As the accepted answer you could add the edge-case to your answer (see my answer).
– Joffrey
22 mins ago
add a comment |
@MrWhite: You are right of course. Silly me ...
– Sven♦
28 mins ago
As the accepted answer you could add the edge-case to your answer (see my answer).
– Joffrey
22 mins ago
@MrWhite: You are right of course. Silly me ...
– Sven♦
28 mins ago
@MrWhite: You are right of course. Silly me ...
– Sven♦
28 mins ago
As the accepted answer you could add the edge-case to your answer (see my answer).
– Joffrey
22 mins ago
As the accepted answer you could add the edge-case to your answer (see my answer).
– Joffrey
22 mins ago
add a comment |
Without validating, but using my experience in Apache rewriting, this configuration seems to:
- Match on the 'path' part of the URI (not the server, port, or query parameters), for example '/my/location/file.html'.
- Match if this part does not end on a '/' (forward-slash) character, -or- does not include a '.' (dot) character.
- Use the full path part of the URI and append a forward-slash to it.
- Send a HTTP 301 (permanent) redirect to direct the browser to this new URI.
This will result in the following test cases
/ -> /
/test -> /test/
/my/resource -> /my/resource/
/my/resource.type -> /my/resource.type
/edge.case/resource -> /edge.case/resource
So I think the rule has a purpose of adding slashes to resources that do not seem to be a file, but it seems to have an edge-case.
If not adding a slash to a resource with '.' (dot) character in the non-file part of the path the regular expression should be changed to:
# match paths which do not end with a slash, or do not resemble a file with an extension
RewriteCond %{REQUEST_URI} !(/$|.[^/]*)
# redirect permanently to the same uri with a slash
RewriteRule (.*) %{REQUEST_URI}/ [R=301]
add a comment |
Without validating, but using my experience in Apache rewriting, this configuration seems to:
- Match on the 'path' part of the URI (not the server, port, or query parameters), for example '/my/location/file.html'.
- Match if this part does not end on a '/' (forward-slash) character, -or- does not include a '.' (dot) character.
- Use the full path part of the URI and append a forward-slash to it.
- Send a HTTP 301 (permanent) redirect to direct the browser to this new URI.
This will result in the following test cases
/ -> /
/test -> /test/
/my/resource -> /my/resource/
/my/resource.type -> /my/resource.type
/edge.case/resource -> /edge.case/resource
So I think the rule has a purpose of adding slashes to resources that do not seem to be a file, but it seems to have an edge-case.
If not adding a slash to a resource with '.' (dot) character in the non-file part of the path the regular expression should be changed to:
# match paths which do not end with a slash, or do not resemble a file with an extension
RewriteCond %{REQUEST_URI} !(/$|.[^/]*)
# redirect permanently to the same uri with a slash
RewriteRule (.*) %{REQUEST_URI}/ [R=301]
add a comment |
Without validating, but using my experience in Apache rewriting, this configuration seems to:
- Match on the 'path' part of the URI (not the server, port, or query parameters), for example '/my/location/file.html'.
- Match if this part does not end on a '/' (forward-slash) character, -or- does not include a '.' (dot) character.
- Use the full path part of the URI and append a forward-slash to it.
- Send a HTTP 301 (permanent) redirect to direct the browser to this new URI.
This will result in the following test cases
/ -> /
/test -> /test/
/my/resource -> /my/resource/
/my/resource.type -> /my/resource.type
/edge.case/resource -> /edge.case/resource
So I think the rule has a purpose of adding slashes to resources that do not seem to be a file, but it seems to have an edge-case.
If not adding a slash to a resource with '.' (dot) character in the non-file part of the path the regular expression should be changed to:
# match paths which do not end with a slash, or do not resemble a file with an extension
RewriteCond %{REQUEST_URI} !(/$|.[^/]*)
# redirect permanently to the same uri with a slash
RewriteRule (.*) %{REQUEST_URI}/ [R=301]
Without validating, but using my experience in Apache rewriting, this configuration seems to:
- Match on the 'path' part of the URI (not the server, port, or query parameters), for example '/my/location/file.html'.
- Match if this part does not end on a '/' (forward-slash) character, -or- does not include a '.' (dot) character.
- Use the full path part of the URI and append a forward-slash to it.
- Send a HTTP 301 (permanent) redirect to direct the browser to this new URI.
This will result in the following test cases
/ -> /
/test -> /test/
/my/resource -> /my/resource/
/my/resource.type -> /my/resource.type
/edge.case/resource -> /edge.case/resource
So I think the rule has a purpose of adding slashes to resources that do not seem to be a file, but it seems to have an edge-case.
If not adding a slash to a resource with '.' (dot) character in the non-file part of the path the regular expression should be changed to:
# match paths which do not end with a slash, or do not resemble a file with an extension
RewriteCond %{REQUEST_URI} !(/$|.[^/]*)
# redirect permanently to the same uri with a slash
RewriteRule (.*) %{REQUEST_URI}/ [R=301]
edited 7 mins ago
answered 28 mins ago
JoffreyJoffrey
1,441712
1,441712
add a comment |
add a comment |
Richard1984 is a new contributor. Be nice, and check out our Code of Conduct.
Richard1984 is a new contributor. Be nice, and check out our Code of Conduct.
Richard1984 is a new contributor. Be nice, and check out our Code of Conduct.
Richard1984 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Server Fault!
- 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%2fserverfault.com%2fquestions%2f955402%2fcant-figure-out-a-htaccess-rule%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