dotMobimobiThinkingmobiForgemobiReadyDeviceAtlasgoMobi

Posted by Tomsey 5 years 27 weeks ago

pic
 Tomsey
Mobile Addict
Posts: 37
Joined: 5 years ago
[offline]

Often, the internet explorer (IE) browser will not show sites that use .xhtml pages. It will instead show a download prompt. However, some sites that are using .xhtml files or pages like apparently domainpeople.mobi, show perfectly fine in IE. What is the issue there? Is it that the server is not sending the correct mime type to the browser?

And regarding using .htaccess files to make .xhtml available as a default page. Is this the proper way to do it or must one set it up on the server to include .xhtml as a default?

Thanks for your help.

Posted by mobiSiteGalore 5 years ago

pic
 mobiSiteGalore
mobiForge Newbie
Posts: 4
Joined: 5 years ago
[offline]

By default IE does not recognize XHTML.

Option 1: So in order to view it in IE you need to make changes in Apache web server.
By adding the below statement in apache httpd.conf we can solve the IE filetype issue with .xhtml files.

AddType text/html .xhtml

By adding the above line in apache, IE will treat XHTML like HTML.

Option 2: If you have a share server and do not have access to the httpd.conf file then add the line to the htaccess and it would work.
This 2nd option will also be very useful in a larger hosting environment where multiple websites reside.

I do not see any problem or drawback raising as a result of adding the "AddType text/html .xhtml" in the .htaccess file. To the best of my knowledge this will make the site still compatible with all other mobile & desktop browsers.

Please make this change and it would then start to work in IE.

http://www.mobisitegalore.com

Posted by Tomsey 5 years ago

pic
 Tomsey
Mobile Addict
Posts: 37
Joined: 5 years ago
[offline]

Hi. Thank you very much.

I added that code along with:

DirectoryIndex index.html index.htm index.xhtml index.html.var index.php index.php3 index.php4

to the htaccess file and the site now works fine in IE however, if I go to validate that particular site at the w3c validator, I get a mime type error. The error is:

"The MIME Media Type (text/html) for this document is used to serve both SGML and XML based documents, and it is not possible to disambiguate it based on the DOCTYPE Declaration in your document. Parsing will continue in SGML mode.

Namespace Found in non-XML Document Namespace "" found, but document type is not XML! "

Thanks for your help.

Posted by Jo Rabin 5 years ago

pic
 Jo Rabin
dotMobi logo
Mobile Addict
Posts: 34
Joined: 5 years ago
[offline]

The reason for this is that xhtml being xml is supposed to be served with the content type "application/xhtml+xml" - the W3 validator takes note of the content type and when it sees text/html it assumes that the document is not an XML document and so throws a wobbly on namespaces and other strictly xml artefacts.

Equally, as you note, the IE browsers do not recognise application/xhtml+xml as something they want to deal with. Firefox and Opera both work fine with it. As should the majority of mobile browsers.

Firefox and Opera don't seem to mind if you serve it as text/html, but I am told that a lot of mobile browsers either choke or suffer a heavy cold when they see it. Most of them are expecting to see application/vnd.wap.xhtml+xml as the content type (XHTML Mobile profile, but equally they SHOULD be OK with application/xhtml+xml).

Changing the content type of XHTML files globally to text/html is therefore not all that wise. You'll serve OK to desktop browsers but stand the risk of making mobile brosers choke. That's not good at all on a dotMobi site.

In the medium term, be comforted that we are keenly aware of this issue in the Best Practices Working Group at W3C and working on this even as we speak.

As an immediate fix, look at the following W3C Mobile technique ServingContentWithDoubleContentType

This does two things:
a) looks for the string MSIE in the incoming user agent string and if it finds it sends the content as text/html
b) looks to check what the browsers preferred content type is and acts on it appropriately.

However be aware that this will also find MSIE in the User Agent strings from Windows Mobile devices, and to be perfectly honest I do not know how they respond to text/html. I will find out.

Also be aware that the actual proposal is to use XHTML Basic 1.1 (not 1.0) but that hasn't quite hit the streets yets.

It would be nice if there a simple clean solution to this. We are looking for one.

Hope this helps.
Jo

PS. Warning on UTF-8 and php.

Note that the content is supposed to be utf-8 encoded. If you save the file as utf-8 you must make sure your editor does not insert the Unicode Byte Order Mark at the front of the file. (e.g. Notepad does this) - because php takes the BOM as the start of content and won't allow you to change the headers after it has sent it. This is incredibly difficult to spot, of course, as the BOM is not visible in the file.

Posted by Tomsey 5 years ago

pic
 Tomsey
Mobile Addict
Posts: 37
Joined: 5 years ago
[offline]

Hi. Thank you for your in-depth response regarding this.