Apache ErrorDocument依赖于浏览器语言

问题描述 投票:0回答:2

我们想创建一个不同的语言页面,这取决于浏览器语言,但它没有拿起fr和zh错误页面,有谁知道我错过了什么?

RewriteCond %{HTTP:Accept-Language} ^fr [NC]
ErrorDocument 404 /notfound_fr.html

RewriteCond %{HTTP:Accept-Language} ^zh [NC]
ErrorDocument 404 /notfound_zh.html

#RewriteCond %{HTTP:Accept-Language} !(^fr|^zh) [NC]
ErrorDocument 404 /notfound.html
apache mod-rewrite errordocument
2个回答
0
投票

正如Deadooshka所说,解决方案是:

RewriteCond %{HTTP:Accept-Language} ^zh [NC]
RewriteRule ^/notfound.html$ /notfound_zh.html [P,L]

RewriteCond %{HTTP:Accept-Language} ^fr [NC]
RewriteRule ^/notfound.html$ /notfound_f.html [P,L]

0
投票

我目前正在为我的.htaccess测试类似下面的代码。到目前为止,它运作良好:

<If "req('accept-language') =~ m#^fr#i">
ErrorDocument 404 /notfound_fr.html
</If>
<ElseIf "req('accept-language') =~ m#^zh#i">
ErrorDocument 404 /notfound_zh.html
</ElseIf>
<Else>
ErrorDocument 404 /notfound.html
</Else>
© www.soinside.com 2019 - 2024. All rights reserved.