I've been struggling with this for two days right now.
At the moment I have the following rewrite rule:
RewriteRule ^(.*)$ index.php?u=$1 [NC,L]
Which ports everything behind example.com/ to index.php as the GET variable u. Which is being processed in index.php with an explode to define te different arguments being: the city (between the first slashes) en the location (the second argument)
THis works perfectly for the following urls:
example.com/City/location/ or example.com/City/location
example.com/City/ or example.com/City
Which produces:
$arg[0] = city
$arg[1] = location
The problem happens when the location has an Ampersand in the location name:
example.com/city/location&more
translates to:
index.php?u=city/location&more
The problem is obvious; i can't use the explode parameter in index.php anymore because the second part of the location name is not stored in $_GET['u'].
How can i solve this?
I think of three solutions which i don't know how to implement:
1) rewriting the rewrite rule to split the city and location in the .htaccess
2) using a .htaccess equivalent of urlencode to transform the &-sign to %26
3) a complete other solution:)
Thanx in advance!
Edit Firstly: When the link is being produced by my website it gets translated with urlencode. So there isn't a & where there shouldn't be one. The & is part of a business namen like: "Bagels&Beans" When people want to search that company they type: www.example.com/city/bagels&beans in the url-field. ANd that is where the problem starts.
edit 2 When i go to: example.com/city/bagels%26Beans it translates to the following: $_GET:
Array
(
[u] => city/Bagels
[Beans] =>
)
edit 3 The way i explode the $_GET['u'] to form the arguments.
$arg = explode('/',$_GET['u']);