Frank Helligberger Frank Helligberger - 1 year ago 124
HTTP Question

HTTP Bad Request error because of a character

I am using .htaccess to convert a link with the following parameters...:

All shirts are with a discount of 20%

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
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?

Answer Source

As stated by Nordenheim the problem is using special characters in your title attribute.

Using PHP you may well want to use urlencode() on your title attribute on the sending link,



$title = "All shirts are with a discount of 20%";
$link = urlencode($title);

<a href='<?php print $link;?>'>Click here</a>

This will turn All shirts are with a discount of 20% into the URL safe string All+shirts+are+with+a+discount+of+20%25 and will resolve the error you are getting from your .htaccess mod_rewrite.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download