I am using .htaccess to convert a link with the following parameters…:
www.domain.com/ offer.php?id=
1000&title=
All shirts are with a discount of 20%
to
www.domain.com/ offer/
1000/
All shirts are with a discount of 20%
Now when I try opening the link I get displayed a server side error:
Bad Request
Your browser sent a request that this server could not understand.
In my code the title
value does not play any role, but I need it for SEO reasons. So when I remove the “%” character from the link the page opens without a problem.
So how can I fix this issue so my link will open despite the percentage character in the HTTP request?
2
Answers
The percent sign (
%
) is used to encode special characters in a url string. Hence, it has special meaning, and must be passed as an encoded character, which is%25
.Since you pass an indication of a special character and do not send anything else, you get the error.
As stated by Nordenheim the problem is using special characters in your title attribute.
Using PHP you may well want to use
urlencode()
on yourtitle
attribute on the sending link,So:
This will turn
All shirts are with a discount of 20%
into the URL safe stringAll+shirts+are+with+a+discount+of+20%25
and will resolve the error you are getting from your.htaccess
mod_rewrite.