Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this in your .htaccess:</p> <p><strong>.htaccess</strong></p> <pre><code>ErrorDocument 404 http://example.com/404/ ErrorDocument 500 http://example.com/500/ # or map them to one error document: # ErrorDocument 404 /pages/errors/error_redirect.php # ErrorDocument 500 /pages/errors/error_redirect.php RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} ^/404/$ RewriteRule ^(.*)$ /pages/errors/404.php [L] RewriteCond %{REQUEST_URI} ^/500/$ RewriteRule ^(.*)$ /pages/errors/500.php [L] # or map them to one error document: #RewriteCond %{REQUEST_URI} ^/404/$ [OR] #RewriteCond %{REQUEST_URI} ^/500/$ #RewriteRule ^(.*)$ /pages/errors/error_redirect.php [L] </code></pre> <p>The <code>ErrorDocument</code> redirects all 404s to a specific URL, all 500s to another url (replace with your domain). </p> <p>The Rewrite rules map that URL to your actual 404.php script. The RewriteCond regular expressions can be made more generic if you want, but I think you have to explicitly define all ErrorDocument codes you want to override.</p> <p><strong>Local Redirect:</strong></p> <p>Change .htaccess ErrorDocument to a file that exists (must exist, or you'll get an error):</p> <pre><code>ErrorDocument 404 /pages/errors/404_redirect.php </code></pre> <p><strong>404_redirect.php</strong></p> <pre><code>&lt;?php header('Location: /404/'); exit; ?&gt; </code></pre> <p><strong>Redirect based on error number</strong></p> <p>Looks like you'll need to specify an <code>ErrorDocument</code> line in .htaccess for every error you want to redirect (see: <a href="http://httpd.apache.org/docs/current/mod/core.html#errordocument">Apache ErrorDocument</a> and <a href="http://httpd.apache.org/docs/current/custom-error.html">Apache Custom Error</a>). The <strong>.htaccess</strong> example above has multiple examples in it. You can use the following as the generic redirect script to replace 404_redirect.php above.</p> <p><strong>error_redirect.php</strong></p> <pre><code>&lt;?php $error_url = $_SERVER["REDIRECT_STATUS"] . '/'; $error_path = $error_url . '.php'; if ( ! file_exists($error_path)) { // this is the default error if a specific error page is not found $error_url = '404/'; } header('Location: ' . $error_url); exit; ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload