# .htaccess extension hiding breaks W3C validation

**URL:** <https://forum.kirupa.com/t/htaccess-extension-hiding-breaks-w3c-validation/264791>\
**Category:** programming\
**Created:** [June 30, 2008, 4:01pm UTC](https://forum.kirupa.com/t/htaccess-extension-hiding-breaks-w3c-validation/264791 "2008-06-30T16:01:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zbbtt](https://avatars.discourse-cdn.com/v4/letter/z/f08c70/32.png) [@zbbtt](https://forum.kirupa.com/u/zbbtt)\
**Post date:** [June 30, 2008, 4:01pm UTC](https://forum.kirupa.com/t/htaccess-extension-hiding-breaks-w3c-validation/264791/1 "2008-06-30T16:01:16Z")

</div>

Hello,

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

```auto
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 &lt;?xml version="1.0"?&gt;) 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

Validation Output: 78 Error

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

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

---

<div class="post-metadata">

**Author:** ![evildrummer](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/evildrummer/32/2308_2.png) [@evildrummer](https://forum.kirupa.com/u/evildrummer)\
**Post date:** [June 30, 2008, 4:31pm UTC](https://forum.kirupa.com/t/htaccess-extension-hiding-breaks-w3c-validation/264791/2 "2008-06-30T16:31:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sekasi](https://avatars.discourse-cdn.com/v4/letter/s/5f8ce5/32.png) [@sekasi](https://forum.kirupa.com/u/sekasi)\
**Post date:** [June 30, 2008, 4:52pm UTC](https://forum.kirupa.com/t/htaccess-extension-hiding-breaks-w3c-validation/264791/3 "2008-06-30T16:52:39Z")

</div>

Try this instead;

```auto

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

```

---

<div class="post-metadata">

**Author:** ![zbbtt](https://avatars.discourse-cdn.com/v4/letter/z/f08c70/32.png) [@zbbtt](https://forum.kirupa.com/u/zbbtt)\
**Post date:** [June 30, 2008, 5:05pm UTC](https://forum.kirupa.com/t/htaccess-extension-hiding-breaks-w3c-validation/264791/4 "2008-06-30T17:05:55Z")

</div>

> 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! 😉  
> (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. ☹  
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.
