Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bad Request Your browser sent a request that this server could not understand

Tags:

apache

ubuntu

Although I am by no means an expert on Ubuntu, I have had two servers running for a couple of years with no problems.

Last night, when attempting to access a local website on one of them I got the error:

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

After several hours of frustration and no success, I rebuilt the server. While Ubuntu was installing I went to the other server and got the exact same error. The first server has now been rebuilt and it displays the same error.

I have shut down every computer on the network. Powered down the router and started over.

In addition to the two servers, the network consists of three windows machines and a Ubuntu desktop.

I have tried isolating the machines from the Internet, I have tried both wired and wireless clients.

Going to localhost on the servers displays the Ubuntu Apache Default page.

The only thing that happened about the time the problem started was the Windows decided to shutdown this machine for an update. I don't see how this could have caused a problem but I have isolated this machine from the network and the problem exists.

I cleared cookies, used five different browsers, and they all report the same error. I'm about out of ideas, and looking for any suggestions.

like image 652
Dave Davis Avatar asked May 11 '17 21:05

Dave Davis


People also ask

Why does my browser keep saying bad request?

The most common reason for a 400 Bad Request error is because the URL was typed wrong or the link that was clicked on points to a malformed URL with a specific kind of mistake in it, like a syntax problem. This is most likely the problem if you get a 400 Bad Request error.

How do I fix bad requests in Firefox?

Chosen solutionClear the cache and cookies only from websites that cause problems. "Clear the Cache": Firefox/Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"


2 Answers

In my case, it's actually the underscore _ in DocumentRoot that causes problem and hours of debugging. All work fine once I remove it from my DocumentRoot path.

like image 95
Nero Avatar answered Sep 22 '22 17:09

Nero


This is due to the update RFC 3986, which claims that underscores are unsafe in virtual host servernames and other elements. In my case, I could not change the URL name, so I just allowed this underscores by enabling these unsafe urls. To do that, just add HttpProtocolOptions unsafe to the httpd.conf file.

https://httpd.apache.org/docs/2.4/mod/core.html#httpprotocoloptions

like image 24
Nan Avatar answered Sep 18 '22 17:09

Nan