Can't figure out a htaccess ruleWhy does this mod_rewrite rule 'not-match'? (big rewrite log included)Can...

Did ancient Germans take pride in leaving the land untouched?

Do the speed limit reductions due to pollution also apply to electric cars in France?

Is there any way to play D&D without a DM?

Can you say "leftside right"?

Can someone explain what a key is?

Integer but not Laurent sequences

Isn't a semicolon (';') needed after a function declaration in C++?

Does Plato's "Ring of Gyges" have a corrupting influence on its wearer?

Can't figure out a htaccess rule

Manager has noticed coworker's excessive breaks. Should I warn him?

When does a person lose diplomatic status?

How to transport 10,000 terrestrial trolls across ocean fast?

Missing a connection and don't have money to book next flight

Converting numbers to words - Python

How bad is a Computer Science course that doesn't teach Design Patterns?

What is formjacking?

Is it possible to detect 100% of SQLi with a simple regex?

What is an efficient way to digitize a family photo collection?

Why don't you get burned by the wood benches in a sauna?

How can I give a Ranger advantage on a check due to Favored Enemy without spoiling the story for the player?

Will the duration of traveling to Ceres using the same tech developed for going to Mars be proportional to the distance to go to Mars or not?

Is the tritone (A4 / d5) still banned in Roman Catholic music?

What is wrong with my use of "find -print0"?

Is there any danger of my neighbor having my wife's signature?



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
            48 mins ago











          • As the accepted answer you could add the edge-case to your answer (see my answer).

            – Joffrey
            42 mins ago



















          2














          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
              48 mins ago











            • As the accepted answer you could add the edge-case to your answer (see my answer).

              – Joffrey
              42 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
              48 mins ago











            • As the accepted answer you could add the edge-case to your answer (see my answer).

              – Joffrey
              42 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 46 mins ago

























            answered 50 mins ago









            SvenSven

            86.8k10144198




            86.8k10144198













            • @MrWhite: You are right of course. Silly me ...

              – Sven
              48 mins ago











            • As the accepted answer you could add the edge-case to your answer (see my answer).

              – Joffrey
              42 mins ago



















            • @MrWhite: You are right of course. Silly me ...

              – Sven
              48 mins ago











            • As the accepted answer you could add the edge-case to your answer (see my answer).

              – Joffrey
              42 mins ago

















            @MrWhite: You are right of course. Silly me ...

            – Sven
            48 mins ago





            @MrWhite: You are right of course. Silly me ...

            – Sven
            48 mins ago













            As the accepted answer you could add the edge-case to your answer (see my answer).

            – Joffrey
            42 mins ago





            As the accepted answer you could add the edge-case to your answer (see my answer).

            – Joffrey
            42 mins ago













            2














            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






























              2














              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




























                2












                2








                2







                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 28 mins ago

























                answered 48 mins ago









                JoffreyJoffrey

                1,451712




                1,451712






















                    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

                    Щит и меч (фильм) Содержание Названия серий | Сюжет |...

                    Венесуэла на летних Олимпийских играх 2000 Содержание Состав...

                    Meter-Bus Содержание Параметры шины | Стандартизация |...