views:

19

answers:

1

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]
A: 

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

bobince
It astounds me that it was something so simple, but thank you very much.
Darpeh