Forum Moderators: phranque
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;charset=utf-8]
I tried doing this:
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;charset=utf-8]
RewriteRule /stats/\.html$ - [T=text/html;charset=utf-8]
which didn't work. I'm a bit out of my depth with regexps and mod_rewrite, so can anyone give me a clue as to where to start looking?
Thanks
RewriteRule ^(.*)\.html$ $1.html [T=application/xhtml+xml;charset=utf-8]
RewriteRule ^(.*)/stats/(.*)\.html$ $1/stats/$2 [T=text/html;charset=utf-8]
After looking around, I did find some exampes using your sytntax, so I stand corrected.
RewriteRule /stats/.+\.html$ - [T=text/html;charset=utf-8]
Ignore the first two lines I posted. The last line should get you fixed up.
RewriteRule /stats/.+\.html$ - [T=text/html;charset=utf-8]
If the /stats/ folder is located in the public root of your domain(eg. domain.com/stats/), then you should remove the first slash and add the start anchor(caret).
RewriteRule ^stats/.+\.html$ - [T=text/html;charset=utf-8]
I hope this helps.
Birdman
Add another RewriteCond to your original code that says if(not /stats) rewrite to xml.
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
RewriteCond %{REQUEST_URI}!^path/to/stats/
RewriteRule \.html$ - [T=application/xhtml+xml;charset=utf-8]
You will need to adjust the path part(the right side).
Note: Make sure to add the space between the closing bracket(}) and the exclamation(!). The forum software strips them for some reason.
RewriteRule ^stats/.+\.html$ - [T=text/html;charset=utf-8]
to the file works a treat. I did try your idea for rewriting based on whether the request wasn't pointed at the stats directory but interestingly I got a server error for any .html page I tried to pull regardless of it's location. Oh well, at least it's working. Thanks!