.htaccess & and %26 both splitting $_GET

早过忘川 提交于 2019-12-22 01:02:48

问题


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]

回答1:


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



来源:https://stackoverflow.com/questions/3791584/htaccess-and-26-both-splitting-get

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!