2

I have some problems for rendering a custom error page for my website. Joomla is installed at the root of my domain.

I have created an error.php page inside templates/mytemplate/ directory but this page is not rendered every time I insert a wrong url.

Some examples follows to better explain my problem with typed url and corresponding obtained page:

  • www.example.org/something-not-existing --> not custom error page (see below)
  • www.example.org/index.php/something-not-existing --> home page
  • www.example.org/index.php?option=com_component-not-existing --> custom error page, 404 Component not found
  • www.example.org/index.php?option=com_existing-component&view=not-existing-view --> custom error page, 500 View not found

Not custom error page:

Not Found

The requested URL /something-not-existing was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


Why I don't get the custom error page also in the first two cases?

1
  • 1
    Could you please add all the contents of your error.php file to pastebin.com so we can take a look?
    – Lodder
    Commented Oct 27, 2015 at 16:52

3 Answers 3

1

ErrorDocument 404 /templates/mytemplate/error.php

Is NOT the way to do this. All Joomla requests get routed through index.php and NOT direct to the error page.

Add

ErrorDocument 404 default
ErrorDocument 401 default

in your .htaccess to overwrite your servers configuration and trigger Joomla's built in handler. Also ensure that your server is configured to allow rewriting of urls. You should use the default Joomla htaccess.txt as a base for your own .htaccess file, with the inclusion of the above two lines.

0

You can try add in your .htaccess

RewriteEngine On
ErrorDocument 404 /templates/mytemplate/error.php
1
  • Thanks, this partially works. The server finds the correct error file to render but it seems that all joomla variables are undefined so I get inly a blank page
    – Red
    Commented Oct 27, 2015 at 16:10
0

This probably is because you don't use the .htaccess file (or it hasn't been correctly configured).

When typing your URL without index.php, it gives the standard 404 error page because Joomla is not even loaded, and can't present the custom 404 error page (I'm assuming this - not sure about the technical details).

Try renaming htaccess.txt to .htaccess in your Joomla root folder. You might have to uncomment the following line, but this depends on your server settings:

RewriteBase /

You should now get your custom error page for all your examples above.

Hope this helps.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.