Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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: http://stackoverflow.com/questions/7246497/htaccess-query-string-urldecode and http://stackoverflow.com/questions/8464298/rewrite-and-url-decoding

share|improve this question

1 Answer 1

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.

share|improve this answer
    
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. –  toomanyairmiles 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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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