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

    2. <small id='BFEkT'></small><noframes id='BFEkT'>

      .htaccess url 用变量重写

      .htaccess url rewrite with variables(.htaccess url 用变量重写)

          • <tfoot id='kBDtJ'></tfoot>
              <tbody id='kBDtJ'></tbody>
          • <small id='kBDtJ'></small><noframes id='kBDtJ'>

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

                <i id='kBDtJ'><tr id='kBDtJ'><dt id='kBDtJ'><q id='kBDtJ'><span id='kBDtJ'><b id='kBDtJ'><form id='kBDtJ'><ins id='kBDtJ'></ins><ul id='kBDtJ'></ul><sub id='kBDtJ'></sub></form><legend id='kBDtJ'></legend><bdo id='kBDtJ'><pre id='kBDtJ'><center id='kBDtJ'></center></pre></bdo></b><th id='kBDtJ'></th></span></q></dt></tr></i><div id='kBDtJ'><tfoot id='kBDtJ'></tfoot><dl id='kBDtJ'><fieldset id='kBDtJ'></fieldset></dl></div>
              • 本文介绍了.htaccess url 用变量重写的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我试图通过使用重写来更改我网站上特定子目录中的网址:
                www.example.com/sub/file/{some_number}/内部:
                www.example.com/sub/file.php?var={some_number}
                我不断收到 404.我已经使用如下所示的 .htaccess 文件从我的网站中删除了 .php 扩展名:

                I'm trying to make my urls look prettier in a specific subdirectory on my site by using rewrite to change:
                www.example.com/sub/file/{some_number}/ internally to:
                www.example.com/sub/file.php?var={some_number}
                And I keep getting a 404. I'm already removing the .php extension from my site using an .htaccess file that looks like this:

                RewriteEngine on
                #
                ## Internally rewrite extensionless file requests to .php files ##
                #
                # If the requested URI does not contain a period in the final path-part
                RewriteCond %{REQUEST_URI} !(.[^./]+)$
                # and if it does not exist as a directory
                RewriteCond %{REQUEST_FILENAME} !-d
                # and if it does not exist as a file
                RewriteCond %{REQUEST_FILENAME} !-f
                # then add .php to get the actual filename
                RewriteRule (.*) /$1.php [L]
                #
                ## Externally redirect clients directly requesting .html page URIs to extensionless URIs
                #
                # If client request header contains html file extension
                RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /([^.]+.)+html HTTP
                # externally redirect to extensionless URI
                RewriteRule ^(.+).html$ http://www.dirtycoffee.com/$1 [R=301,L]
                
                # If client request header contains php file extension
                RewriteCond %{THE_REQUEST} ^[A-Z]{3,9} /([^.]+.)+php HTTP
                # externally redirect to extensionless URI
                RewriteRule ^(.+).php$ http://www.dirtycoffee.com/$1 [R=301,L]
                

                我目前的尝试是在顶部添加一行,例如:

                My current attempt is to add a line at the top like:

                #Subdirectory rewrite:
                RewriteRule ^sub/file/([0-9]+)/?$ sub/file?num=$1 [L] # Handle requests for file
                

                我知道我一定有相互冲突的规则,但我认为如果应用新规则,[L] 就会停止.

                I know I must have conflicting rules, but I thought [L] would just stop if the new rule was applied.

                推荐答案

                代替:

                RewriteRule ^sub/file/([0-9]+)/?$ sub/file?num=$1 [L]
                

                试试:

                RewriteRule ^sub/file/([0-9]+)/?$ /sub/file.php?num=$1 [L]
                

                [L] 将停止处理规则是正确的,但这也意味着您不能消除 .php 扩展名,因为它的规则低于此规则.还要注意前导斜杠.

                You're correct that [L] will stop processing rules, but that also means that you can't eliminate the .php extension since the rule for that is below this one. Also note the leading slash.

                这篇关于.htaccess url 用变量重写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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 的问题)
                    <legend id='7Oqcx'><style id='7Oqcx'><dir id='7Oqcx'><q id='7Oqcx'></q></dir></style></legend>
                    <i id='7Oqcx'><tr id='7Oqcx'><dt id='7Oqcx'><q id='7Oqcx'><span id='7Oqcx'><b id='7Oqcx'><form id='7Oqcx'><ins id='7Oqcx'></ins><ul id='7Oqcx'></ul><sub id='7Oqcx'></sub></form><legend id='7Oqcx'></legend><bdo id='7Oqcx'><pre id='7Oqcx'><center id='7Oqcx'></center></pre></bdo></b><th id='7Oqcx'></th></span></q></dt></tr></i><div id='7Oqcx'><tfoot id='7Oqcx'></tfoot><dl id='7Oqcx'><fieldset id='7Oqcx'></fieldset></dl></div>
                    • <bdo id='7Oqcx'></bdo><ul id='7Oqcx'></ul>
                    • <small id='7Oqcx'></small><noframes id='7Oqcx'>

                          <tbody id='7Oqcx'></tbody>

                        <tfoot id='7Oqcx'></tfoot>