我有两种语言的网站,英语和荷兰语。在PHP中构建多语言(多语言)网站的自定义404页面
英语版本是在根目录(的public_html)和荷兰的版本是在/ NL /目录。
我的网站是用PHP编写的。
当链接中断(页面移动或不存在了)时,我希望荷兰语的人(荷兰语和比利时人)被重定向到荷兰语的404页面,其余的翻译成英语的404页面。
如何创建自定义404错误页面为这个多语言(多语言)的网站?请给我一个完整的代码例如(PHP和/或.htaccess)。
我.htacces文件包含以下行:
# Instructs webbrowsers how to cache content
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 5 minutes"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
# Rewrite non-www to www
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteEngine on
RewriteRule ^(.*)\.html$ $1.php [nc]
# Error Page(s)
ErrorDocument 404 /404.php
不起作用。当我在/ nl /目录外键入一个错误的url时,它显示error_nl.html版本。它总是显示nl版本。 – Mickel
你的'.htaccess'文件是否包含更多行?你能把它的内容放在一些pastebin中吗?你使用哪个版本的Apache? <?的PHP的phpinfo()>的溶液中的Apache 2.4.9 – Dekel
进行测试时我运行它显示以下信息: 阿帕奇1.3(apache_hooks)\t 阿帕奇1.3 \t Apache 2.0的过滤\t Apache 2.0的处理程序(基于在Apache 2.0筛选器代码上) – Mickel