.htaccess extension hiding breaks W3C validation

Hello,

I’m using the following to hide the .xhtml extension from a site’s addresses.

AddType text/html .xhtml
DirectoryIndex perfil.xhtml
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.xhtml -f
RewriteRule ^(.*)$ $1.xhtml

The xhtml files themselves are valid, but the lack of extension gives me this (and other related) errors when trying to validate them with W3Cs validation tool:

  1. Unable to Determine Parse Mode!
  The validator can process documents either as XML (for document types such as XHTML, SVG, etc.) or SGML (for HTML 4.01 and prior versions). For this document, the information available was not sufficient to determine the parsing mode unambiguously, because:
      * the MIME Media Type (text/html) can be used for XML or SGML document types
      * the Document Type (-//W3C//DTD XHTML; 1.0 Strict//EN) is not in the validator's catalog
      * No XML declaration (e.g <?xml version="1.0"?>) could be found at the beginning of the document.

  As a default, the validator is falling back to SGML mode.
  1. Warning Namespace Found in non-XML Document

    Namespace “” found, but the -//W3C//DTD XHTML; 1.0 Strict//EN document type is not an XML document type!

Validation Output: 78 Error

  1. Error Line 237, Column 27: omitted tag minimization parameter can be omitted only if OMITTAG NO is specified.

    … And the list goes on and on with omitted tag errors (again, if I check the xhtml files, they’re valid).

How can I fix this? Thank you very much for any assistance!

^ What is your doctype? Chances are it’s slightly wrong. I’ve never had that error

Try this instead;


AddType text/html .xhtml
DirectoryIndex perfil.xhtml
Options +FollowSymLinks +Indexes
RewriteEngine on
RewriteBase /
RewriteRule ^([^.]+)\.xhtml$ $1 [L]

What is your doctype? Chances are it’s slightly wrong. I’ve never had that error
The doctype declaration is valid, this is just my Apache magic that isn’t working! :wink:
(Guessing the validator looks for the .xhtml extension, doesn’t find it and freaks out?)

Sekasi, thank you, I’ve tried what you posted, but now I get a 404 on all the pages. :frowning:
Any idea why?

** After some help at the webmasterworld forum, I found the culprit: the page I was trying to validate lacked the xml declaration, without the extension, the validator would spit in my eye. It’s fixed now. Thank you for your help as well.