我有兩種語言的網站,英語和荷蘭語。在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