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

  • <small id='3o6Hq'></small><noframes id='3o6Hq'>

        <tfoot id='3o6Hq'></tfoot>
          <bdo id='3o6Hq'></bdo><ul id='3o6Hq'></ul>
      1. 当目录存在时用htaccess重写url

        时间:2023-09-23
      2. <tfoot id='ZzCEW'></tfoot>
            <bdo id='ZzCEW'></bdo><ul id='ZzCEW'></ul>
              <tbody id='ZzCEW'></tbody>

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

          • <small id='ZzCEW'></small><noframes id='ZzCEW'>

                  本文介绍了当目录存在时用htaccess重写url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试将动态页面重定向到目录,例如:

                  I'm trying to redirect a dynamic page to a dir, example:

                  url.com/index.php?page=download
                  to
                  url.com/download
                  

                  规则很简单:

                  RewriteRule ^download$ /index.php?page=download
                  

                  完整的.HTACCESS

                  FULL .HTACCESS

                  RewriteEngine On
                  RewriteBase /
                  
                  RewriteCond %{HTTP_HOST} !^www.url.com$
                  RewriteRule ^(.*) http://url.com/$1 [R=301,L]
                  
                  Redirect 301 /index.php?page=download http://url.com/download
                  RewriteCond %{ENV:REDIRECT_STATUS} 200
                  RewriteRule .* - [L]
                  RewriteRule ^download$ /index.php?page=download
                  

                  问题是我已经有一个名为download"的目录,它返回一个403 Forbidden Error".我注意到将目录重命名为与规则使用的名称(下载)不同的任何名称都可以.

                  The problem is that I already have a directory named "download" and it's returning me a "403 Forbidden Error". I have noticed that renaming the directory to anything different than the name (download) the rule is using will work.

                  所以,我的问题是:如何按照我需要的方式重写我的 url 并保留目录?

                  So, my question is: how can I have my url rewritten the way I need and keep the directory?

                  -- 编辑 --

                  默认情况下,我的服务器使用403 Forbbiden 错误"保护每个目录.我相信这是它不起作用的原因,但我不确定.真的有冲突吗?发生了什么?

                  My server, by default, protects every directory with a "403 Forbbiden Error". I believe this is the reason why it's not working, but I'm not sure. Is it a conflict indeed? What is happening?

                  推荐答案

                  /download/?page=download
                  

                  发生这种情况的原因是因为某处 mod_dir 将所有对缺少尾部斜杠的目录的请求重定向到包含尾部斜杠.这会干扰您的重写规则.由于您的服务器已自动设置为拒绝列出目录,因此继续关闭目录斜杠可能是安全的:

                  The reason why this is happening is because somewhere mod_dir redirects all requests for directories that are missing the trailing slash to include the trailing slash. This is interferring with your rewrite rule. Since your server is automatically setup to deny listing of directories, it's probably safe to go ahead and turn directory slashes off:

                  DirectorySlash Off
                  

                  答案:https://stackoverflow.com/users/851273/jon-lin

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

                  上一篇:.htaccess 替换(重写)PHP URL 中的 $_GET 变量 下一篇:如何删除laravel中的public文件夹

                  相关文章

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

                  1. <tfoot id='lGG0z'></tfoot>

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