• <bdo id='nwSxQ'></bdo><ul id='nwSxQ'></ul>

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

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

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

        如何使用 htaccess 规则停止直接执行 php 页面?

        How to stop direct execution of a php page using htaccess rules?(如何使用 htaccess 规则停止直接执行 php 页面?)
        • <bdo id='x2VwJ'></bdo><ul id='x2VwJ'></ul>
          <tfoot id='x2VwJ'></tfoot>

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

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

                2. 本文介绍了如何使用 htaccess 规则停止直接执行 php 页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在我的 .htaccess 文件中,我定义了以下规则以使我的注册页面 URL 为 http://example.com/register/

                  In my .htaccess file I have defined the following rule to make my register page URL as http://example.com/register/

                  RewriteRule register/ /register.php
                  

                  上述规则非常好,但我可以从 http://example.com/register/ 以及从 http://example.com/register 访问我的注册页面.php.

                  The above rule is perfectly fine but I can access my register page from http://example.com/register/ as well as from http://example.com/register.php.

                  我不希望该用户能够从 http://example.com/register.php URL 访问 URL,是否有任何我可以在 .htaccess 中定义的规则停止执行 register.php URL 或简单地将任何直接 register.php 请求重定向到/register/

                  I don't want that user will be able to access the URL from http://example.com/register.php URL, is there any RULE which I can define in .htaccess to stop execution of register.php URL or simply redirect any direct register.php request to /register/

                  推荐答案

                  如果您这样做是为了避免获得指向同一内容的多个链接,您就不能在页面的任何位置使用register.php".我认为没有搜索引擎会猜测"某种文件类型,如果没有安全问题,你就安全了,因为在我看来,也没有用户会链接到这个文件.但是,如果您想确定只需通过 .htaccess 中的一行通过 index.php 重新路由所有功能,该行应放置在您的 www-root 目录中:

                  If you are doing this to avoid getting multiple links to the same content, you can simply don't use "register.php" anywhere on your page. I think no search engine will "guess" for a certain file type and if there are no security concerns you are on the safe side, because in my opinion no user will link to this file either. However if you want to be certain just reroute all your functionality through an index.php via one line in your .htaccess which should be placed inside your www-root directory:

                  RewriteEngine on
                  RewriteRule ^(.*?)$ index.php?file=$1
                  

                  在您的 index.php 中,您可以通过分解和检查 $_GET["file"] 参数来简单地选择要调用的函数/文件.为了 100% 确定没有人可以直接访问您的 register.php 文件,只需将它(以及您的所有其他文件)移动到一个单独的目录中,并包含一个 .htaccess 文件和以下行:

                  In your index.php you can then simply choose which function/file to invoke by breaking down and checking the $_GET["file"] parameter. To make 100% certain no one can access your register.php file directly just move it (and all your others) to a separate directory and include a .htaccess file with the following line:

                  DENY from all 
                  

                  还有其他几个选项可以防止直接访问.只需 define() 在你的 index.php 和 register.php 的顶部放置一个变量

                  There are a couple of other options to prevent direct access. Just define() a variable somewhere in your index.php and at the top of your register.php just put

                  defined('access') or die('Intruder alert!');
                  

                  在顶部.另一种方法可能是诚实地告诉搜索引擎您的内容已被移动,他们不应再使用旧链接:

                  at the top. Another way could be to be honest and simply tell search engines that your content has been moved and that they no longer should use the old link:

                  header("Status: 301"); /* Content moved permanently */
                  header("Location: http://yourserver/Register/");
                  exit;
                  

                  更新

                  还有一件让我想到的事情,您还可以检查 $_SERVER["REQUEST_URI"],用户是否附加了任何.php",并通过完全拒绝访问或仅拒绝访问来采取相应措施重定向到新位置.

                  Just one more thing that crossed my mind, you can also check $_SERVER["REQUEST_URI"], whether the user attached any ".php" and act accordingly by either denying access completely or just redirecting to the new location.

                  这篇关于如何使用 htaccess 规则停止直接执行 php 页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 的问题)

                  <tfoot id='yy2yO'></tfoot>

                    <tbody id='yy2yO'></tbody>
                3. <legend id='yy2yO'><style id='yy2yO'><dir id='yy2yO'><q id='yy2yO'></q></dir></style></legend>
                    <bdo id='yy2yO'></bdo><ul id='yy2yO'></ul>

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

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