Ori*_*iol 8 regex apache if-statement escaping slash
我想将.xhtml文件作为
application/xhtml+xml 如果浏览器说它接受了它.text/html 除此以外我尝试过这样做mod_rewrite但它不起作用Options -FollowSymLinks(如果我有'Options -FollowSymLinks`,那么在查看受Apache RewriteRule影响的文件时,为什么我会得到403 Forbidden?).
然后,我试过了
<Files "*.xhtml">
<If "%{HTTP:Accept} !~ /application\/xhtml\+xml/">
ForceType text/html
</If>
</Files>
Run Code Online (Sandbox Code Playgroud)
但我得到一个语法错误:无法编译正则表达式.
同时,我用这个代码......
<Files "*.xhtml">
<If "%{HTTP:Accept} !~ /xhtml\+xml/">
ForceType text/html
</If>
</Files>
Run Code Online (Sandbox Code Playgroud)
...有效,但我想匹配正确的MIME类型.
从Apache 2.4开始,似乎仍在构建中.相反,Apache团队成员"covener" 建议 m#regexp#.
所以你的代码看起来像这样......
<If "%{HTTP:Accept} !~ m#application/xhtml\+xml#">
Run Code Online (Sandbox Code Playgroud)