1

I have a htaccess problem with some URLs that contains the % simbol.

For example: .......he-lost-10%-of-his-money.html

Bad Request Your browser sent a request that this server could not understand. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

In my htaccess:

RewriteRule ^([^/]+).html$ abc.php?url=$1 [L]

What must I do?

easwee
  • 15,757
  • 24
  • 60
  • 83
John V
  • 61
  • 2
  • 7

3 Answers3

1

Depending on what you're trying to do, see here:

.htaccess mod rewriterule and ampersands (first answer, applicable for % character if you're passing the URL)

htaccess to escape percent (%) from URL

.htaccess mode_rewrite match percent symbol problem

urlencoded Forward slash is breaking URL

... https://stackoverflow.com/search?q=htaccess+percent

If the content of url= isnt the originating/requested script but a passed variable, you will need to rawurlencode it in the orginating PHP script.

Community
  • 1
  • 1
SW4
  • 69,876
  • 20
  • 132
  • 137
  • The problem is that I currently have more than 9000 urls indexed on Google with this error... I would like to repair them withou lost the indexed urls... – John V Oct 06 '11 at 11:20
  • If thats the case, the fix needs to be established within the .htaccess – SW4 Oct 06 '11 at 11:22
1

% has a special meaning in the URL (and very significant one) and thus it ought to be properly urlencoded. Or change it with word "percent" which is even better for SEO purposes.

mega6382
  • 9,211
  • 17
  • 48
  • 69
Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
  • The problem is that I currently have more than 9000 urls indexed on Google with this error... I would like to repair them withou lost the indexed urls... – John V Oct 06 '11 at 11:22
0

When encoding a URL so special characters can be passed through (such as a space character), they are converted into hex digits, prepended with the % character. Your URL contains the sequence %-o, which is not valid and causes Apache to throw the error. Try that same URL, but replace the % with %25 and see how it goes.

Geoff Adams
  • 1,121
  • 6
  • 15
  • The problem is that I currently have more than 9000 urls indexed on Google with this error... I would like to repair them withou lost the indexed urls... – John V Oct 06 '11 at 11:22