Belgin Fish
Belgin Fish

Reputation: 19837

Remove % Signs From Url Through Htaccess

I'm currently receiving some 400 bad request errors on urls around my site which contain % signs. These urls are not generated on the website but have somehow been picked up by google.

An example url is

http://example.com/file/download/1/%s.html

I'm wondering how I can rewrite these urls to remove the % sign.

Upvotes: 1

Views: 67

Answers (1)

Jon Lin
Jon Lin

Reputation: 143886

Don't think you're going to be able to do anything about this. I'm assuming that because this is generating a 400, the % isn't encoded, as in, the request is literally:

/file/download/1/%s.html

and not

/file/download/1/%25s.html

Because the % is a reserved character, if apache sees the %s in the request, it assumes that the 2 characters after the % is a hex number and tries to decode it, and s. isn't valid so it returns a 400 bad request.

This request is never even handed off to the URL processing pipeline, so mod_rewrite or anything else you put in an htaccess file will never see it.

Upvotes: 2

Related Questions