Today I had to move a website for a client. The website is very old, and is written in ASP, and was hosted on a shared host.
The former developer wanted to have SEO friendly URLs but didn't have a URL Rewrite module available.
What he did was making a custom 404 error page, that would redirect the SEO URL and take care of the error if the URL shouldn't be redirected. As part of the script, he took the QUERY_STRING and processed it like so:
Urlstring = Request.ServerVariables("QUERY_STRING")
Response.Write UrlString
Response.Write URLDecode( UrlString )
Long story short, when moved, this code started to result in a very weird behavior. The QUERY string of international URL's turned to "???" question marks. After checking the settings for IIS, and making sure all the correct code pages are set, I found out that the behavior is changing depending if the text was before or after the '?' in the URL.
For instance, the following URL:
http://www.example.com/something.asp?something=something
If you replaced 'something.asp' with international characters, they would turn to question marks, but if you replaced 'something=something' with international characters they would display properly.
After some trial and error the solution was to use "HTTP_URL" instead of "QUERY_STRING" and strip out a part of it, like so:
Urlstring = Request.ServerVariables("HTTP_URL")
Set RegularExpressionObject = New RegExp
With RegularExpressionObject
.Pattern = "\/err404\.asp\?"
.IgnoreCase = True
.Global = True
End With
UrlString = RegularExpressionObject.Replace(UrlString, "")
Set RegularExpressionObject = nothing
Response.Write UrlString
Response.Write URLDecode( UrlString )
Of course, this is just a quick and dirty RegExp example, and I wouldn't advise using RegExp because they're expensive on memory and resources, but I think you're good to go from here.
Any other ideas? Feel welcome to ask questions or comment!
5 comments:
Hello,
I have the same problem but I use Javascript. I tried your solution by using decodeURIComponent but... nothing to do... same problem
That's weird. What do you get as the HTTP_URL, and what do you get as QUERY_STRING?
Hi danny, I tried your solution and nothing is working. I'm on this for two weeks now and I'm desperate.
Please help me if you can...
Maybe it's something in my iis configuration. I installed hebrew on my server and still, nothing.
Interesting and informative information.I am very happy to see this type article.Thank you for your great sharing.
I have same while using Javascript. Anyways I got some useful information from this website. Hoping more useful post from you.
http://essaywriting-servicereviews.com/Forum-Travel-and-Tourism
http://essaywriting-servicereviews.com/Forum-Fashion-and-Beauty
http://essaywriting-servicereviews.com/Forum-Games-Computers-Tech-Support
Post a Comment