Welcome to WebmasterWorld Guest from 54.162.139.105

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

406 server header errors with MultiViews

and an AddHandler in .htaccess

     
8:39 am on May 24, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 19, 2004
posts:84
votes: 0


I'm parsing *.htm files for php using this in .htaccess:

AddType application/x-httpd-php .htm

I also use URLs which omit the .htm extension, e.g. www.example.com/myfile => myfile.htm using this in .htaccess:

Options +MultiViews

I recently checked my server headers and in some server header checkers, a 406 "Not Acceptable" error is being returned. For example, here's the output from one such server header checker:

HTTP Status Code: HTTP/1.1 406 Not Acceptable 
Date: Wed, 24 May 2006 08:11:53 GMT
Server: Apache/2.0.52
Alternates: {"index.htm" 1 {type application/x-httpd-php} {language en-gb} {length 3327}}
Vary: negotiate
TCN: list
Content-Length: 446
Connection: close
Content-Type: text/html; charset=iso-8859-1

I suppose this is because the index.htm is specified as type application/x-httpd-php. But--oddly--the Content-Type header is still text/html (which is correct). To complicate things further, the charset of all my pages is utf-8, whereas the charset used here is iso-8859-1. I am wondering if my utf-8 charset is only actually applied when the index.htm page is finally served...but that's not the reason for this post. Stay with me here.

Now, if I check my server headers in the WW server header checker [webmasterworld.com] I see that a good ol' 200 is returned:

HTTP/1.1 200 OK 
Date: Wed, 24 May 2006 08:16:56 GMT
Server: Apache/2.0.52
Content-Location: index.htm
Vary: negotiate,Accept,Accept-Encoding
TCN: choice
Content-Encoding: gzip
Content-Length: 3266
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html;charset=utf-8
Content-Language: en-gb

All what I was hoping to see. My pages all load in any browser which I have tried, and seeing pages in a browser is not my problem.

I am concerned that search engine bots--particularly Googlebot--are going to receive a 406 and not index my pages.

Is there any way I can still parse my .htm pages for php, but then offer them truly as text/html first time round (I am assuming the WW server header check just gets past the 406 error by accepting index.htm as type application/x-httpd-php, after which the index.htm file is served as text/html).

All rather confusing. Can anyone shed any light?

9:17 am on May 24, 2006 (gmt 0)

Junior Member

10+ Year Member

joined:Feb 19, 2004
posts:84
votes: 0


I think I've got it (on Apache/2.0.52 with PHP4.3.10 as a module).

Instead of getting the server to parse .htm files for php using the

AddType application/x-httpd-php .htm
line, I used this:

AddHandler php-script htm

My pages are working the same as before--PHP is parsed ok--and now the server header checkers which were getting 406's are now getting the lovely "200 OK".

It seems to be working (you'd need to use "AddHandler php5-script htm" if you're running php5).

1:01 pm on May 24, 2006 (gmt 0)

Senior Member

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Mar 31, 2002
posts:25430
votes: 0


AddType declares the MIME-type of files on your server.

Since you declared .htm files to be 'application', that is, 'executable or to be run, handled, or processed on the client side by other than the browser' with your 'AddType application/x-httpd-php' directive, and the first server header checker had in all likelihood stated in its "Accept" header that it could only accept text/html or text/plain, the server, having no text/html file to return, responded with Not Acceptable.

Your solution is correct; use AddHandler, not AddType.

Jim