<i id='GbyOq'><tr id='GbyOq'><dt id='GbyOq'><q id='GbyOq'><span id='GbyOq'><b id='GbyOq'><form id='GbyOq'><ins id='GbyOq'></ins><ul id='GbyOq'></ul><sub id='GbyOq'></sub></form><legend id='GbyOq'></legend><bdo id='GbyOq'><pre id='GbyOq'><center id='GbyOq'></center></pre></bdo></b><th id='GbyOq'></th></span></q></dt></tr></i><div id='GbyOq'><tfoot id='GbyOq'></tfoot><dl id='GbyOq'><fieldset id='GbyOq'></fieldset></dl></div>
        <bdo id='GbyOq'></bdo><ul id='GbyOq'></ul>

      <small id='GbyOq'></small><noframes id='GbyOq'>

      1. <tfoot id='GbyOq'></tfoot>
        <legend id='GbyOq'><style id='GbyOq'><dir id='GbyOq'><q id='GbyOq'></q></dir></style></legend>
      2. RewriteRule htaccess 总是删除尾部斜杠偶数目录

        RewriteRule htaccess to always remove trailing slash even directory(RewriteRule htaccess 总是删除尾部斜杠偶数目录)
        <tfoot id='IE53r'></tfoot>

      3. <i id='IE53r'><tr id='IE53r'><dt id='IE53r'><q id='IE53r'><span id='IE53r'><b id='IE53r'><form id='IE53r'><ins id='IE53r'></ins><ul id='IE53r'></ul><sub id='IE53r'></sub></form><legend id='IE53r'></legend><bdo id='IE53r'><pre id='IE53r'><center id='IE53r'></center></pre></bdo></b><th id='IE53r'></th></span></q></dt></tr></i><div id='IE53r'><tfoot id='IE53r'></tfoot><dl id='IE53r'><fieldset id='IE53r'></fieldset></dl></div>

        <small id='IE53r'></small><noframes id='IE53r'>

            • <bdo id='IE53r'></bdo><ul id='IE53r'></ul>
                <tbody id='IE53r'></tbody>

                <legend id='IE53r'><style id='IE53r'><dir id='IE53r'><q id='IE53r'></q></dir></style></legend>

                • 本文介绍了RewriteRule htaccess 总是删除尾部斜杠偶数目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  目标是结合几个规则:

                  • 在 URI 中永远不要有斜杠
                  • 在调用 domain.tld/somedir 时内部重写为 index.php (domain.tld/somedir/index.php)
                  • 删除文件扩展名,检查 + '.php' 是否存在并最终在内部对其进行重写
                  • never have a trailing slash in the URI
                  • internally rewrite to the index.php (domain.tld/somedir/index.php) when calling domain.tld/somedir
                  • remove file extensions, check if + '.php' exists and eventually internally rewrite to it

                  这将在.htaccess"中完成,因为这是我唯一可访问的.

                  This is to be done in '.htaccess' as this is my only accessible .

                  我目前的尝试

                  # check if *.php exists
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteCond %{REQUEST_FILENAME}.php -f
                  RewriteRule ^(.*[^/])/?$ $1.php [L, QSA]
                  
                  # do not allow trailing slash
                  RewriteRule (.*)/ $1 [L, R=301]
                  

                  这里的难点在于查询domain.tld/somedir"在被重定向到domain.tld/somedir/"后通常会调用目录的index.php.但是,我希望在查询domain.tld/somedir"时在内部调用 index.php(没有 301)直接.

                  The difficulty here is that the query 'domain.tld/somedir' normally calls the directory's index.php after having been redirected to 'domain.tld/somedir/'. However, I would like the index.php to be internally called (no 301) directly when querying 'domain.tld/somedir'.

                  推荐答案

                  您可以使用以下代码:

                  DirectoryIndex index.php
                  RewriteEngine On
                  
                  # remove trailing slash
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteCond %{THE_REQUEST} s(.+?)/+[?s]
                  RewriteRule ^(.+?)/$ /$1 [R=301,L]
                  
                  # To internally forward /dir/file to /dir/file.php
                  RewriteCond %{REQUEST_FILENAME} !-d
                  RewriteCond %{DOCUMENT_ROOT}/$1.php -f [NC]
                  RewriteRule ^(.+?)/?$ /$1.php [L]
                  

                  这篇关于RewriteRule htaccess 总是删除尾部斜杠偶数目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                      <tbody id='pN7Qq'></tbody>
                  • <small id='pN7Qq'></small><noframes id='pN7Qq'>

                      <tfoot id='pN7Qq'></tfoot>
                        <bdo id='pN7Qq'></bdo><ul id='pN7Qq'></ul>
                          <legend id='pN7Qq'><style id='pN7Qq'><dir id='pN7Qq'><q id='pN7Qq'></q></dir></style></legend>

                        • <i id='pN7Qq'><tr id='pN7Qq'><dt id='pN7Qq'><q id='pN7Qq'><span id='pN7Qq'><b id='pN7Qq'><form id='pN7Qq'><ins id='pN7Qq'></ins><ul id='pN7Qq'></ul><sub id='pN7Qq'></sub></form><legend id='pN7Qq'></legend><bdo id='pN7Qq'><pre id='pN7Qq'><center id='pN7Qq'></center></pre></bdo></b><th id='pN7Qq'></th></span></q></dt></tr></i><div id='pN7Qq'><tfoot id='pN7Qq'></tfoot><dl id='pN7Qq'><fieldset id='pN7Qq'></fieldset></dl></div>