For some reason I am getting 404 errors in my log file because of users trying to access something like http ://www.domain.tld%3Fid%3D222 instead of http://www.domain.tld?id=222

I've unsuccessfully tried all sort of rewrite rules. Is there a way to decode URIs from Apache?

Related questions: https://stackoverflow.com/questions/7246497/htaccess-query-string-urldecode and https://stackoverflow.com/questions/8464298/rewrite-and-url-decoding


The htaccess syntax is this:

Redirect 301 "/%3Fid%3D222" http://www.domain.tld?id=222

Note the quotes around the ASCII characters in the first URL.

If it's a problem for multiple addresses then you might want to ask one of the regex gurus at StackOverflow to help you out.

  • Yes, it is more complicated than this. domain.com/a/index.php%3Fid%3DUSERID%26whatever%3Dsmth rewritten to domain.com/indexNEW.php?id=USERID&whatever=smth It is a mix of url decode and forward to a new structure. Regrettably I (we are two) did not get a solution.
    – dstonek
    May 22 '12 at 16:09
  • @dstonek I've had the same problem, but only for a small number of poorly crafted urls, so the above fixed my problem. I'd suggest posting at Stackoverflow with the code you've tried. They have some good people over there for this sort of thing. May 22 '12 at 17:59
  • Mines are lot old ones. Luckily almost all are from a deprecated site structure so I got a way to avoid error 404 and get the right url. I'll post it in my stackoverflow question I posted in 2011 (the second link from my question here). I still don't why that was the original problem. The other guy (the first post link) tells a problem with hotmail atachments names.
    – dstonek
    May 22 '12 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.