【问题标题】:htaccess how to convert special charshtaccess 如何转换特殊字符
【发布时间】:2012-03-23 08:40:42
【问题描述】:

我需要使用 $_GET 在 PHP 中获取病毒,我的 .htaccess 重写了 url:

localhost/arpege/gm/ 到 localhost/arpege/index.php?code=gm

这是我的 .htaccess 的代码:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ index.php?code=$1

但是当我输入 localhost/arpege/p&p/ 时,我只能使用 $_GET 获得第一个 p!

我想使用 $_GET 获取 p&p

谁能帮我解决这个问题?

【问题讨论】:

    标签: regex apache .htaccess mod-rewrite


    【解决方案1】:

    将您的 RewriteRule 更改为:

    RewriteRule ^(.*)$ index.php?code=$1 [L,QSA]
    

    【讨论】:

    • 我之前尝试过,但没有成功,而是将我带到了一个不正确的网址(禁止访问):localhost/D:/AppServ/www/arpege/index.php?code=p&p。无论如何,这不会将 '&' 转换为 %26,对吗?
    • 您可以尝试RewriteRule ^(.*)$ /index.php?code=$1 [L,QSA,NE] 此外,'&' to %26 conversion 在您手动键入 URL 时发生在浏览器本身。如果它是代码的一部分,那么您可以通过编程方式获得像 localhost/arpege/p%26p/ 这样的 URL。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-10-03
    • 1970-01-01
    • 2022-07-10
    • 2012-04-01
    • 2019-11-04
    • 2012-07-10
    • 1970-01-01
    相关资源
    最近更新 更多