【问题标题】:How to send $_GET values with .htaccess如何使用 .htaccess 发送 $_GET 值
【发布时间】:2016-08-07 02:58:40
【问题描述】:

我想使用 GET 将 id 发送到其他页面。我正在使用其他人构建的脚本。通常的http://<site>/<page>?id=1 不起作用。

htaccess

RewriteEngine On
RewriteRule ^([^/]+)-([0-9]+)$ /index.php?page=$1&p=$2 [L]
RewriteRule ^([^/]+)-([0-9]+)([^/]+)$ /index.php?page=$1&p=$2&del [L]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1

【问题讨论】:

    标签: php apache .htaccess mod-rewrite


    【解决方案1】:

    你的问题不清楚 如果您希望有人回答您,请编辑问题。

    正如我从你的问题中了解到的那样,你想将值表单页面传递给 php 中的另一个页面 像这样没关系

    <HTML>
        <BODY>
           <form action="index.php" method="get">
             <input name="value" type="text">
             <input name="submit" type="supmit">
           <form>
        </BODY>
    </HTML>
    

    index.php

     if(isset($_GET['submit']){
     echo $_GET['value'];
     // or do something using the values got
    }
    

    【讨论】:

      【解决方案2】:

      如果我理解正确,查询字符串在通过上述重写规则运行时没有传递。

      所以跟随this answer我建议你尝试将QSA添加到所有规则中,如下所示:

      RewriteEngine On
      RewriteRule ^([^/]+)-([0-9]+)$ /index.php?page=$1&p=$2 [L,QSA]
      RewriteRule ^([^/]+)-([0-9]+)([^/]+)$ /index.php?page=$1&p=$2&del [L,QSA]
      RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [QSA]
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2020-04-14
        • 2016-05-02
        • 1970-01-01
        • 2012-09-09
        • 2012-03-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多