htaccess的&放大器;和26%这两个分裂$ _ GET [英] .htaccess & and %26 both splitting $_GET

查看:131
本文介绍了htaccess的&放大器;和26%这两个分裂$ _ GET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的.htaccess文件为这个特殊物品的文件夹。我的问题是由PHP脚本时收到这些URL既分割$ _ GET变量。

  1. /food-and-diet/articles/test-&-cake.html
  2. /food-and-diet/articles/test-%26-cake.html

这两个网址创建这个$ _GET数组:

 阵列([文章] =>测试 -  [-cake] => [文件夹] =>无)
 


 选项+了FollowSymLinks
    RewriteEngine叙述上
    的RewriteBase /食品和饮食/
    重写规则^ +(/ CSS /.+)$ $ 1 [L]
    重写规则^ +(/ JS /.+)$ $ 1 [L]
    重写规则^ +(/图像/.+)$ $ 1 [L]
    重写规则^ \ index.html的$的index.php [NC,L]
    重写规则^文章/ $的index.php指数= $ 1安培;?文章=无&放大器;文件夹=无[NC,L]
    重写规则^文章/([^.^/]+)/?$ index.php的文章=无&安培;文件夹= $ 1 [NC,L]
    重写规则^文章/([^ /] +)\。JPG $文章/ $ 1.JPG [L]
    重写规则^文章/([^ /] +)\。GIF $文章/ $ 1.gif [L]
    重写规则^文章/([^ /] +)PNG \ $文章/ $ 1.png [L]
    重写规则^文章/([^ /] +)\ HTML $的index.php文章= $ 1安培;?文件夹=无[NC,L]
    重写规则^文章/([^。^ /] +)/([^ /] +)\。JPG $篇/ $ 1 / $ 2.JPG [L]
    重写规则^文章/([^。^ /] +)/([^ /] +)\。GIF $篇/ $ 1 / $ 2.gif [L]
    重写规则^文章/([^。^ /] +)/([^ /] +)PNG \ $文章/ $ 1 / $ 2.png [L]
    重写规则^文章/([^ ^ /] +)/([^ /] +)\ HTML $的index.php文章= $ 2及?文件夹= $ 1 [NC,L]
 

解决方案

使用的 B 标志正确逃生匹配路径的一部分进入查询部分。

Below is my .htaccess file for this particular articles folder. My problem is that these urls both split the $_GET variable when received by the php script.

  1. /food-and-diet/articles/test-&-cake.html
  2. /food-and-diet/articles/test-%26-cake.html

Both of these urls create this $_GET array:

Array ( [article] => test- [-cake] => [folder] => none )


Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /food-and-diet/
    RewriteRule ^.+(/css/.+)$ $1 [L]
    RewriteRule ^.+(/js/.+)$ $1 [L]
    RewriteRule ^.+(/images/.+)$ $1 [L]
    RewriteRule ^\index.html$ index.php [NC,L]
    Rewriterule ^articles/?$ index.php?index=$1&article=none&folder=none [NC,L]
    Rewriterule ^articles/([^.^/]+)/?$ index.php?article=none&folder=$1 [NC,L]
    RewriteRule ^articles/([^/]+)\.jpg$ articles/$1.jpg [L]
    RewriteRule ^articles/([^/]+)\.gif$ articles/$1.gif [L]
    RewriteRule ^articles/([^/]+)\.png$ articles/$1.png [L]
    Rewriterule ^articles/([^/]+)\.html$ index.php?article=$1&folder=none [NC,L]
    RewriteRule ^articles/([^.^/]+)/([^/]+)\.jpg$ articles/$1/$2.jpg [L]
    RewriteRule ^articles/([^.^/]+)/([^/]+)\.gif$ articles/$1/$2.gif [L]
    RewriteRule ^articles/([^.^/]+)/([^/]+)\.png$ articles/$1/$2.png [L]
    Rewriterule ^articles/([^.^/]+)/([^/]+)\.html$ index.php?article=$2&folder=$1 [NC,L]

解决方案

Use the B flag to properly escape a matched path part into a query part.

这篇关于htaccess的&放大器;和26%这两个分裂$ _ GET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆