Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
392 views
in Technique[技术] by (71.8m points)

PHP Apache 406 Not Acceptable when php file doesn't have the php extension in the URL

I'm using dropzone for file uploads and for some reason if I access the page where the plugin is and the page doesn't have the .php in the URL then I get "406 not acceptable" error when I drop a file into the dropzone area. if I load the page using the .php extension on the URL then it works just fine.

I was breaking my head following other's suggestions on how to fix the 406 error and now I am even more confused because it works with the .php extension (or .html extension) on the URL but not otherwise.

I tried adding to the the following parameters.

  1. AddHandler type-map var
  2. MultiviewsMatch Handlers Filters

I tried adding to the .htaccess the following parameters.

<IfModule mod_security.c>
SecFilterEngineOff
SecFilterScanPOSTOff
</IfModule>

I tried other things but nothing worked and after trying everything I found online, is when I tried to use the .php extension on the URL and dropzone worked just fine. Btw, dropzone requests for "application/json" on the header request, not use if that helps.

any ideas how I can fix the issue of not having the headers accepted when the .php is not part of the filename in the URL?

Thanks in advance,

if you need any other details that might have escaped me, then let me know and I'll gladly update.

EDIT:

when I use the .php extension on the URL, the header response from the server is

Content-Type: text/html; charset=UTF-8

when I load the URL without the .php extension, the header response changes to

Content-Type: text/html; charset=iso-8859-1

while the request header is still the same

Accept: application/json

EDIT:

I edited the .htaccess file and added the following and it works.

<IfModule mod_rewrite.c>
    Options +FollowSymLinks -MultiViews
    RewriteEngine on

    RewriteCond %{REQUEST_URI} !-d
    RewriteCond %{REQUEST_URI}.php !-f
    RewriteRule ^([^.]+)$ $1.php [NC,L]
</IfModule>

Now it seems to work when loading the page without the .php extension, so it seems that the problem has been solved.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...