Custom 404 Page for a Multilingual (multi language) Website built in PHP
<p>I have a website in two languages, english and dutch.</p>

<p>The english version is in the root (public_html) and the dutch version is in the /nl/ directory.</p>

<p>My website is built in PHP.</p>

<p>When a link is broken (page moved or doesn't exist anymore), then I want dutch speaking people (dutch and belgium people) to be redirected to the 404 page in dutch and the rest to the 404 page in english.</p>

<p>How can I create a custom 404 Error page for this multilingual (multi language) website? Please give me a complete code for example (php and/or .htaccess).</p>

<p>My .htacces file contains the following lines:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code># Instructs webbrowsers how to cache content
&lt;IfModule mod_expires.c&gt;
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"
&lt;/IfModule&gt;

# 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</code></pre>
</div>
</div>
</p>