glenelkins Posted July 2, 2010 Share Posted July 2, 2010 is there a way to do this? like a url like /category/Computer & Electronics/ If i parse this the variable only shows Computer (which makes sense!) , I tried replacing & with + and then back again but when I send Computer+Electronics the + is stripped as a white space... Link to comment https://forums.phpfreaks.com/topic/206507-parse-ambersand-in-url/ Share on other sites More sharing options...
Mchl Posted July 2, 2010 Share Posted July 2, 2010 & %26 Link to comment https://forums.phpfreaks.com/topic/206507-parse-ambersand-in-url/#findComment-1080231 Share on other sites More sharing options...
AbraCadaver Posted July 2, 2010 Share Posted July 2, 2010 Yes, an you should be using urlencode() on text that you put in the URL. This will do that for you. Link to comment https://forums.phpfreaks.com/topic/206507-parse-ambersand-in-url/#findComment-1080377 Share on other sites More sharing options...
glenelkins Posted July 3, 2010 Author Share Posted July 3, 2010 even with urlencode() the url for example Computer & Electronics is coming back as just "Computer" when taken from $_GET Link to comment https://forums.phpfreaks.com/topic/206507-parse-ambersand-in-url/#findComment-1080626 Share on other sites More sharing options...
AbraCadaver Posted July 3, 2010 Share Posted July 3, 2010 even with urlencode() the url for example Computer & Electronics is coming back as just "Computer" when taken from $_GET Must be something else in your code. With this: echo '<a href="?test=' . urlencode('Computer & Electronics') . '">Click</a>'; echo $_GET['test']; I get this as the URL: /test.php?test=Computer+%26+Electronics and this from the echo: Computer & Electronics Link to comment https://forums.phpfreaks.com/topic/206507-parse-ambersand-in-url/#findComment-1080699 Share on other sites More sharing options...
glenelkins Posted July 4, 2010 Author Share Posted July 4, 2010 I think its something to do with the htaccess. If i access the url: index.php?route=advertiser/category/computer+%26+electronics .... then echo $_GET['route'] shows advertiser/category/computer+%26+electronics If I use the rewrite urls like: /computer+%26%+electronics ... then echo $_GET['route'] shows advertiser/category/computer this is the rewrite: RewriteRule ^(.*)/$ index.php?route=advertiser/category/$1/ [L] Link to comment https://forums.phpfreaks.com/topic/206507-parse-ambersand-in-url/#findComment-1080951 Share on other sites More sharing options...
glenelkins Posted July 4, 2010 Author Share Posted July 4, 2010 quote: "Apache's mod_rewrite and mod_proxy are unable to handle urlencoded URLs properly - http://issues.apache.org/bugzilla/show_bug.cgi?id=34602" The most simple solution is to use urlencode twice! echo urlencode(urlencode($var)); Apache's mod_rewrite will handle it like a normal string using urlencode once. Link to comment https://forums.phpfreaks.com/topic/206507-parse-ambersand-in-url/#findComment-1080952 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.