【问题标题】:htaccess clean url syntax converts a pipe symbol to %7Chtaccess clean url 语法将管道符号转换为 %7C
【发布时间】:2014-02-13 09:30:09
【问题描述】:

我花了过去 10 个小时来弄清楚我做错了什么,但不幸的是到目前为止没有任何效果......

这就是我的情况:

RewriteRule ^party/(.*)$ party.php?party=$1  [L]

是我在 htaccess 中清理 url 的工作规则。
它工作得很好,但现在我在 $_GET 参数中有一些特殊字符,例如 * 没有转换,但管道符号会转换为 %7C

我检查了party.php?party=$1,它正确显示了所有字符,所以我猜我的 htaccess 语法导致失败......

我也尝试了[NE] 标志,但它不起作用...

有什么想法吗? 非常非常感谢!

我也刚刚意识到 url 在 mozilla 中正确显示...

【问题讨论】:

    标签: mod-rewrite special-characters clean-urls


    【解决方案1】:

    我用:

    Options +FollowSymlinks
    RewriteEngine On
    
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^(.+)?\.testynarkotykowe.xernt.com$ [NC]
    RewriteRule ^(.*)$ http://testynarkotykowe.pl/$1 [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule (.*) index.php
    

    加上你。

        function sUrl() {
            $_GET = explode('/',substr(getenv('REQUEST_URI'),1)); $_pth = PTH;
            if(!empty($_pth)) {
                $pth  = explode('/',PTH);
                for($i = 0; $i < count($_GET); $i++) if($_GET[$i] == $pth[$i]) unset($_GET[$i]);
                array_splice($_GET,0,0);
            } foreach($_GET as $k=>$v) $_GET[$k] = htmlspecialchars($v); /* SECURITY: check for addslashes */
        }
    }
    

    【讨论】:

    • 输入任何链接,即localhost/url1/url2等和var_export($_GET),你会得到$_GET[0] => 'url1'等...
    猜你喜欢
    • 2015-05-25
    • 1970-01-01
    • 1970-01-01
    • 2012-06-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-05
    相关资源
    最近更新 更多