+ Reply to Thread
Results 1 to 5 of 5

Thread: XHTML Madness!

  1. #1
    thorx10 is offline x10Hosting Member thorx10 is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    5

    XHTML Madness!

    I am brand new to web design so please forgive my obvious ignorance.

    I am a little confused about serving an XHTML webpage as application/xhtml+xml. When I do so, and I click View Page Info in Mozilla's (3.5.1) context menu it says that the Type is text/html. Below this, in the Meta section it says:

    Content-Type: application/xhtml+xml; charset=utf-8

    Why does it say the Type is text/html when the Content Type is application/xhtml+xml?

    When I serve the page as php and use a bit of code to detect if the browser can accept the application/xhtml+xml MIME type, Mozilla does in fact display the Type as application/xhtml+xml.

    How can I serve the file as application/xhtml+xml for Firefox (and other browsers) using html only?

    Examples:

    HTML: www.hollowpursuits.x10hosting.com/test (View Page Info)
    PHP: www.hollowpursuits.x10hosting.com/corporama (View Page Info)

    Any help or insight would be greatly appreciated!

    Thanks in advance.
    Last edited by thorx10; 12-27-2009 at 12:48 AM.

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: XHTML Madness!

    How did you try configure Apache to serve "test" as "application/xhtml+xml"? Whatever it was, it didn't work. If you view the "Headers" tab in the Page Info window (or use the Live HTTP Headers add-on), you'll see that Apache sends a "Content-type: text/html" header for the page.
    Last edited by misson; 12-27-2009 at 01:36 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    thorx10 is offline x10Hosting Member thorx10 is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    5

    Re: XHTML Madness!

    Thanks for the reply, and for the Headers add-on.

    I didn't perform any configuration of the Apache server. I simply uploaded the .html file to my x10Hosting subdomain via ftp (the same way I did with the php page). Do I need to configure something in cPanel so that the .html files are served as "application/xhtml+xml" when the Content-Type is "application/xhtml+xml" in the file?

    If it helps, here is the header code used on the php page:

    <?php
    if (stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) {
    header("Content-type: application/xhtml+xml");
    echo '<?xml version="1.0" encoding="utf-8"?'.'>';
    }
    else {
    header("Content-type: text/html; charset=utf-8");
    }
    ?>

    Basically all I want to do is to have the browser use the application/xhtml+xml MIME type when I use a .html file.



    ---Later---


    After some reading on the issue, it seems that I need to add the following to the .htaccess file:

    # XHTML
    AddType application/xhtml+xml .xhtml

    There is a .htaccess file in the public_html directory. Is this the one that should be modified, and if so, where should this code be added within the file?

    Is it possible to edit this via cPanel or should I download the file via ftp, modify it, and upload it again?

    (Sorry, total beginner)



    ---Even later---


    Sorted! I just needed to create a .htaccess file in the appropriate directory with one line of code:

    AddType application/xhtml+xml .html

    (AddType [MIME-type] [extension])

    Thanks misson, for pointing me towards the Apache server. Also, the Live HTTP Headers add-on for Mozilla is made out of win!

    Last edited by thorx10; 12-27-2009 at 05:19 AM. Reason: Automerged Doublepost

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: XHTML Madness!

    Since you had to set the header when using PHP, it's a safe bet that Apache won't do it on its own. After all, Apache is the intermediary between browsers and PHP scripts.

    You can set MIME types within cPanel, but not conditionally. To do that, editing .htaccess is the way to go. AddType is what cPanel uses under the hood; it can only unconditionally set the content type. To conditionally set the Content-type header, you might be able to make use of: SetEnvIf, RewriteCond+RewriteRule, Header. Try something like:
    Code:
    RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml
    RewriteCond %{REQUEST_FILENAME} \.x?html$
    RewriteRule . - [E=XHTML:1]
    
    Header set Content-type "application/xhtml+xml" env=XHTML
    While you're at it, begin to familiarize yourself with the rest of the Apache module documentation, which explains the various Apache configuration options, and which can be used in .htaccess.
    Last edited by misson; 12-27-2009 at 05:51 AM.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  5. #5
    thorx10 is offline x10Hosting Member thorx10 is an unknown quantity at this point
    Join Date
    Sep 2009
    Posts
    5

    Re: XHTML Madness!

    Conditional! Now that's what I'm talking about. I will have a go at this code too.

+ Reply to Thread

Similar Threads

  1. XHTML Madness!
    By thorx10 in forum Graphics & Webdesign
    Replies: 0
    Last Post: 12-26-2009, 11:35 PM
  2. Document type?
    By focus in forum Graphics & Webdesign
    Replies: 5
    Last Post: 09-26-2009, 12:57 PM
  3. xHtml or Html
    By socialnu2 in forum Crossfire
    Replies: 5
    Last Post: 10-06-2008, 09:27 AM
  4. HTML or XHTML?
    By sclewin in forum Crossfire
    Replies: 26
    Last Post: 08-04-2008, 05:38 AM
  5. XHTML valid...
    By DecemberGuild in forum Free Hosting
    Replies: 11
    Last Post: 01-03-2007, 07:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers