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?













1















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?










share|improve this question







New contributor




Richard1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    1















    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?










    share|improve this question







    New contributor




    Richard1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      1












      1








      1








      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?










      share|improve this question







      New contributor




      Richard1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      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






      share|improve this question







      New contributor




      Richard1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Richard1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Richard1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 1 hour ago









      Richard1984Richard1984

      83




      83




      New contributor




      Richard1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Richard1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Richard1984 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          2 Answers
          2






          active

          oldest

          votes


















          2














          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]





          share|improve this answer


























          • @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



















          1














          Without validating, but using my experience in Apache rewriting, this configuration seems to:




          1. Match on the 'path' part of the URI (not the server, port, or query parameters), for example '/my/location/file.html'.

          2. Match if this part does not end on a '/' (forward-slash) character, -or- does not include a '.' (dot) character.

          3. Use the full path part of the URI and append a forward-slash to it.

          4. 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]





          share|improve this answer

























            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.










            draft saved

            draft discarded


















            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









            2














            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]





            share|improve this answer


























            • @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
















            2














            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]





            share|improve this answer


























            • @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














            2












            2








            2







            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]





            share|improve this answer















            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]






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 26 mins ago

























            answered 30 mins ago









            SvenSven

            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



















            • @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













            1














            Without validating, but using my experience in Apache rewriting, this configuration seems to:




            1. Match on the 'path' part of the URI (not the server, port, or query parameters), for example '/my/location/file.html'.

            2. Match if this part does not end on a '/' (forward-slash) character, -or- does not include a '.' (dot) character.

            3. Use the full path part of the URI and append a forward-slash to it.

            4. 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]





            share|improve this answer






























              1














              Without validating, but using my experience in Apache rewriting, this configuration seems to:




              1. Match on the 'path' part of the URI (not the server, port, or query parameters), for example '/my/location/file.html'.

              2. Match if this part does not end on a '/' (forward-slash) character, -or- does not include a '.' (dot) character.

              3. Use the full path part of the URI and append a forward-slash to it.

              4. 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]





              share|improve this answer




























                1












                1








                1







                Without validating, but using my experience in Apache rewriting, this configuration seems to:




                1. Match on the 'path' part of the URI (not the server, port, or query parameters), for example '/my/location/file.html'.

                2. Match if this part does not end on a '/' (forward-slash) character, -or- does not include a '.' (dot) character.

                3. Use the full path part of the URI and append a forward-slash to it.

                4. 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]





                share|improve this answer















                Without validating, but using my experience in Apache rewriting, this configuration seems to:




                1. Match on the 'path' part of the URI (not the server, port, or query parameters), for example '/my/location/file.html'.

                2. Match if this part does not end on a '/' (forward-slash) character, -or- does not include a '.' (dot) character.

                3. Use the full path part of the URI and append a forward-slash to it.

                4. 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]






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 7 mins ago

























                answered 28 mins ago









                JoffreyJoffrey

                1,441712




                1,441712






















                    Richard1984 is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    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.




                    draft saved


                    draft discarded














                    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





















































                    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

                    Szabolcs (Ungheria) Altri progetti | Menu di navigazione48°10′14.56″N 21°29′33.14″E /...

                    Discografia di Klaus Schulze Indice Album in studio | Album dal vivo | Singoli | Antologie | Colonne...

                    How to make inet_server_addr() return localhost in spite of ::1/128RETURN NEXT in Postgres FunctionConnect to...