PDA

View Full Version : Appeal for someone that knows (x)html and htaccess files


DAve
5th July 2005, 23:04
Goal: trying to get xhtml standards browsers to accept xhtml serves web-pages (specifically the GUNS webpage)
That is, firefox, mozilla and opera browsers to recognise the xhtml1.1 as application xml+xhtml and use the fallback IE as html tag soup. Stuff 'em :)

So, the original .htaccess file was sniffing for user agents. I really wanted to avoid this, but couldn't see any way around this. The file is below (well, te important parts anyway.

AddType text/html;charset=utf-8 .html
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} Opera [OR]
RewriteCond %{HTTP_USER_AGENT} Gecko [OR]
RewriteCond %{HTTP_USER_AGENT} Konqueror [OR]
RewriteCond %{HTTP_USER_AGENT} KHTML
RewriteRule \.html$ - [T=application/xhtml+xml]
So reading about the mess that user agents sniffers cause on the web, I learned about http_accept rules. They seem much better, and actually work on what the browser can read. Is there any danger in using them?

Fixed .htaccess file below.
AddType text/html;charset=utf-8 .html
RewriteEngine on
RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml
RewriteRule \.html$ - [T=application/xhtml+xml]

Sideshow
6th July 2005, 09:50
I believe that some browsers (Safari, I think) accept application/xhtml+xml, but don't advertise it. I think your original code would work fine, simply changing the '.xhtml' to a '.html'

Sideshow
6th July 2005, 09:51
and I don't think you need to add the .xhtml extenion, since there are no .xhtml files on the guns site.

DAve
6th July 2005, 13:03
The site works now.

The redirect was borked for a minute, but now seems to work again. I hate using htaccess files.