1

I want to define my custom error document in the htaccess file of wordpress installation. For that i have modified the htaccess file.

MY htacces file looks like this:

# BEGIN WordPress

<IfModule mod_rewrite.c>
ErrorDocument 404 /mysite/script.php
RewriteEngine On
RewriteBase /mysite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mysite/index.php [L]
</IfModule>

# END WordPress

But when i try to load a page that does not exists it goes to wordpress default error page.

What i want is that script.php file should be called when a page is not found.

1 Answer 1

2

From the Codex: The default WordPress theme has a 404.php file, but not all Themes have their own custom 404 error template file. If they do, it will be named 404.php. WordPress will automatically use that page if a Page Not Found error occurs.

http://codex.wordpress.org/Creating_an_Error_404_Page

Now the Wordpress way to handle this would be:

  1. Copy/rename your script.php to 404.php and put it in your theme folder
  2. ErrorDocument 404 /mysite/script.php should read ErrorDocument 404 /mysite/index.php?404
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.