.htaccess&和%26都分裂$ _GET

时间:2010-09-24 22:52:04

标签: .htaccess urlencode

以下是此特定文章文件夹的.htaccess文件。我的问题是这些网址在php脚本收到时都拆分了$ _GET变量。

  1. /food-and-diet/articles/test-&-cake.html
  2. /food-and-diet/articles/test-%26-cake.html
  3. 这两个url都创建了这个$ _GET数组:

    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 个答案:

答案 0 :(得分:3)

使用B flag将匹配的路径部分正确地转义为查询部分。