Forum Moderators: phranque

Message Too Old, No Replies

Couldn't retrieve the right querystring on mod_rewrite

         

jimpoo

11:29 pm on Feb 27, 2004 (gmt 0)

10+ Year Member



See the following .htaccess codes:

------------
Options -MultiViews
RewriteEngine on
RewriteBase /
RewriteRule ^(.*)/(.*) /page.php?v1=$1&v2=$2 [L]
------------

Now I have a string 'wedget™' needed to be placed on the url, so I used urlencode() or rawurlencode() function in the php code to encode the string before placing on the url, and then the url will looks like the following:

mysite.com/wedget™/ID123.html

In the file page.php I use $HTTP_GET_VARS["v1"] to retrieve the string, the problem is that the server couldn't pass the string of 'wedget™' to the parameter v1, so the page.php couldn't retrieve the right value of the string.

This happens to some other special string signs as well.

Generally, the server can retrieve the right values for each parameters on any url format if it is not using mod_rewrite, but how to do this under the mod_rewrite?

Thanks for help!

jdMorgan

12:24 am on Feb 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would strongly advise you to not use special characters in URLs. Your problem with mod_rewrite is only one of several problems you will encounter. Special characters are not allowed in URLs by the HTTP standards, and you will run into constant problems with servers, proxies, caches, browsers, search engines, and others.

The document that controls what characters may be used in URLs and for what purposes is RFC2396 [faqs.org], cited in the HTTP/1.1 specification [webmasterworld.com].

If you incorporate a method not allowed by those documents, there is simply no guarantee that your site will continue to function in the future, and worse yet, that you will have any indication that it is not functioning -- unless you see the error yourself on your own machine using your ISP, their caching proxy, etc.

You are free to do as you please, of course, and therefore I should point out that mod_rewrite has a 'NoEscape' [NE] flag which may be helpful, and that the rules for using special characters in query_strings are somewhat more relaxed.

Jim