问题
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.
- /food-and-diet/articles/test-&-cake.html
- /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