View Full Version : http 406 error Not Acceptable
bradosia
10-18-2009, 09:31 PM
Here is the main scoop, My website (asodar.com (http://asodar.com)) gets a 406 error - Not Acceptable whenever I use a '%' in the url, such as asodar.com/?q=% and asodar.com/search/?q=%. Adding ?q=% after any directory seems to trigger this 406 error.
I have already searched many times to find a solution. I have tried disabling mod_security in my root .htaccess file with:
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
but still no luck fixing the problem.
I have toyed around with it and this is what i found:
asodar.com/?q=% error
asodar.com/?q=%20 fine
asodar.com/?q=%25 error
asodar.com/?%=hi error
asodar.com/?q=40%ofmypie error
I have deleted my whole .htaccess file to see if anything in there caused the problem, though the problem still persists. Adding "?q=%" to the end of any directory on my server gets the error (even blank pages with no coding). While adding it to another website such as google.com gets no error. I have come to the conclusion that the problem lays in the settings of my server, but I have not changed any settings other than in the .htaccess file.
If anyone could assist me in the solution to this problem, it would be very helpful.
oesxyl
10-18-2009, 11:21 PM
% can't be used in a url if is not escaped. If you use php you can use urlencode and urldecode to convert url from one form to another:
http://www.php.net/manual/en/function.urlencode.php
http://www.php.net/manual/en/function.urldecode.php
for perl use URI::Escape module.
http://search.cpan.org/~gaas/URI-1.40/URI/Escape.pm
manualy, :rolleyes:,
http://www.december.com/html/spec/esccodes.html
best regards
drhowarddrfine
10-18-2009, 11:26 PM
A 406 error is sent by the server when you are requesting a page, or resource, for which you have no means of accepting it. It's like requesting a Word file but you have no Word program to read it. Probably because your query string is asking for nonsense but the server can't deliver that in the form it thinks you want.
bradosia
10-19-2009, 07:20 AM
oesxyl, hi, and yes I have already tried urlencode on the % sign. It still returns a 406 error. And I am using php.
drhowarddrfine, Thanks for defining 406 error, though the query is not nonsence. What I am doing is making my own search engine for my own site. The user can type anything in an input box and the query will be sent to another page (php script) and searched for. The form uses get method to send the query so a user typing "I am awesome" in the box and clicking search will be sent to the url "http://asodar.com/search/?q=I+am+awesome". The problem is when the user types a % sign anywhere in the query they will be sent to a 406 page. This occures even with urlencode. The problem is not the php script that processes the request because I have already tried sending the query to a blank script and the 406 still persists. Though I remain confused on what other problem could be causing this error.
oesxyl
10-19-2009, 07:31 AM
oesxyl, hi, and yes I have already tried urlencode on the % sign. It still returns a 406 error. And I am using php.
drhowarddrfine, Thanks for defining 406 error, though the query is not nonsence. What I am doing is making my own search engine for my own site. The user can type anything in an input box and the query will be sent to another page (php script) and searched for. The form uses get method to send the query so a user typing "I am awesome" in the box and clicking search will be sent to the url "http://asodar.com/search/?q=I+am+awesome". The problem is when the user types a % sign anywhere in the query they will be sent to a 406 page. This occures even with urlencode. The problem is not the php script that processes the request because I have already tried sending the query to a blank script and the 406 still persists. Though I remain confused on what other problem could be causing this error.
post please if you can the relevant parts of:
- the form where you get the query string from the user
- the part of htaccess or what ever you use to redirect to the processing script
- the part of the script who process the query string
best regards
bradosia
10-19-2009, 04:00 PM
this is the form located http://asodar.com/articles/
<form action="http://asodar.com/search/" method="GET" name="searcharticles">
<input class="searchinput" type="text" maxlength="100" name="q">
<input type="hidden" name="t" value="article">
<input type="submit" value="Search">
</form>
this is the processing page it goes to (http://asodar.com/search/):
<?
$searcht = urldecode($_GET['t']);
$searchq = urldecode($_GET['q']);
echo "you searched for ".$searchq;
?>
Though the 406 error comes up even before the page is executed
If i make http://asodar.com/search/ a blank page that the query is sent to i get the 406 if there is a % sign in the query
oesxyl
10-21-2009, 04:30 AM
debug what you get, t and q like this:
<?php
echo '<pre>'.$_GET['t'].'</pre>';
echo '<pre>'.$_GET['q'].'</pre>';
$searcht = urldecode($_GET['t']);
$searchq = urldecode($_GET['q']);
echo "you searched for ".$searchq;
?>
you didn't explain how you send the search expresion 'q' to the php file where you process it. You use a redirection in a .htaccess file, or what?
why don't you use the php filename in action attribute of the form instead of that url? maybe this is the cause for the 406?
sorry for the late answer
best regards
bradosia
10-21-2009, 04:36 PM
When the query contains "%" it does not even let me access the page it just sends in a 406. If I type "hello kitty":
echo '<pre>'.$_GET['t'].'</pre>'; - prints article
echo '<pre>'.$_GET['q'].'</pre>'; - prints hello kitty
Sorry, i think i confused you earlier, there is no .htaccess redirection involved.
The php script is at http://asodar.com/search/index.php though i just use http://asodar.com/search/ The php filename is in the form action attribute.
oesxyl
10-21-2009, 05:18 PM
When the query contains "%" it does not even let me access the page it just sends in a 406. If I type "hello kitty":
echo '<pre>'.$_GET['t'].'</pre>'; - prints article
echo '<pre>'.$_GET['q'].'</pre>'; - prints hello kitty
Sorry, i think i confused you earlier, there is no .htaccess redirection involved.
The php script is at http://asodar.com/search/index.php though i just use http://asodar.com/search/ The php filename is in the form action attribute.
use http://asodar.com/search/index.php instead of http://asodar.com/search/ in the action attribute and see what's happend.
best regards
bradosia
10-25-2009, 11:52 PM
sorry for the delayed response, my internet was lost for a few days.
Anyways, after switching to http://asodar.com/search/index.php, It still does not work, it gets the same results.
oesxyl
10-26-2009, 12:41 AM
sorry for the delayed response, my internet was lost for a few days.
Anyways, after switching to http://asodar.com/search/index.php, It still does not work, it gets the same results.
change this:
<form method="post" action="http://asodar.com/process/" name="poplogin" id="pagepopuplogin" style="display: none;">
<div class="loginerror"></div>
to this:
<form method="post" action="http://asodar.com/process/index.php" name="poplogin" id="pagepopuplogin" style="display: none;">
<div class="loginerror"></div>
and test.
best regards
bradosia
10-26-2009, 03:01 AM
Aha!
I have found the problem, it was actually not in the coding, the problem was in the server itself.
I found out that my host had mod_security installed, and I could not disable it because they do not allow you to dissable it in the .htaccess file.
I contacted my host and they disabled it. All i gatta do now is make my scripts secure, but at least I have more freedom.
Thank you oesxyl for your time at help.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.