Page 1 of 2

Customize 404 page.

Posted: Wed Jan 30, 2019 12:39 pm
by xanmean
How to customize 404 page. Thank you.

Re: Customize 404 page.

Posted: Wed Jan 30, 2019 2:24 pm
by Edi
It's easy:
  • Create a page.
  • Go to "Settings" > "General" > "Advanced" and enter the name of the page in the field "Page not found".

Re: Customize 404 page.

Posted: Mon Feb 18, 2019 5:28 pm
by abdulhalim
Hello Edi,

There is not fancy with 404 error page, I customized the template I used, I add author info box and etc to the page, Also the page shows in the menu!
Is there any way to redirect to the HTML page?

Best Regards,
Abdulhalim

Re: Customize 404 page.

Posted: Mon Feb 18, 2019 9:25 pm
by Jay
abdulhalim wrote: Mon Feb 18, 2019 5:28 pm
Is there any way to redirect to the HTML page?
just use apache's error document handler, and point to a static html with below command:

Code: Select all

ErrorDocument 404 /404.html

Re: Customize 404 page.

Posted: Tue Feb 19, 2019 6:22 am
by abdulhalim
Thank you, Jay

I put it into htaccess file, but it doesn't work, I think it needs to edit some of php file to redirect properly.

Regards,
Abdulhalim

Re: Customize 404 page.

Posted: Tue Feb 19, 2019 11:38 pm
by Jay
abdulhalim wrote: Tue Feb 19, 2019 6:22 am Thank you, Jay

I put it into htaccess file, but it doesn't work, I think it needs to edit some of php file to redirect properly.

Regards,
Abdulhalim
I should guess, that easiest methods doesn't work in general.
Basically you should check your access log, and see if the 404.html document is found in the path you use once you hit a "404 - page not found".
Otherwise try with one of below :

Code: Select all

ErrorDocument 404 /absolute/path/to/html/document/on/your/webhost/account/404.html
or

Code: Select all

ErrorDocument 404 http://yourdomain/404.html
try to put this handler before bludit's rewrite commands, as it's more important than cms redirects which ends with [L] (it means, that once they're hit, htaccess won't check further commands)


ps. I assume your webhosting provider uses apache webserwer, or at least has a port of htaccess directives interpreter.

Re: Customize 404 page.

Posted: Wed Feb 20, 2019 8:36 am
by abdulhalim
Thank you, Jay

I used this command before, but this time it doesn't work, also I want to redirect from HTTPS to HTTP, this command doesn't work! but for non-www to www, it's OK.

Maybe there is an issue related to my server.

Thank you anyway

Re: Customize 404 page.

Posted: Wed Feb 20, 2019 10:44 pm
by Edi
abdulhalim wrote: Mon Feb 18, 2019 5:28 pm There is not fancy with 404 error page, I customized the template I used, I add author info box and etc to the page, Also the page shows in the menu!
You can add a condition to the navigation, that excludes the 404 error page. Is it a normal or a static page?

Re: Customize 404 page.

Posted: Thu Feb 21, 2019 5:15 am
by abdulhalim
it's a static page, how can I do that? :shock:

Re: Customize 404 page.

Posted: Thu Feb 21, 2019 3:46 pm
by Edi
Using the theme Blekathlon you can modify the loop with the titles in the file aside.php (in the directory /bl-themes/blekathlon/php) as follows if the slug of your error page is for example "error-404" (line 39):

Code: Select all

                        <?php foreach ($staticContent as $staticPage) : ?>
                        	<?php if ($staticPage->slug() != "error-404") { ?>
                        	<li class="menu-item">
                        	    <a href="<?php echo $staticPage->permalink(); ?>">
                        	        <?php echo $staticPage->title(); ?>
                        	    </a>
                        	</li>
                            <?php } ?>
                        <?php endforeach ?>
instead of

Code: Select all

                        <?php foreach ($staticContent as $staticPage) : ?>
                        	<li class="menu-item">
                        	    <a href="<?php echo $staticPage->permalink(); ?>">
                        	        <?php echo $staticPage->title(); ?>
                        	    </a>
                        	</li>
                        <?php endforeach ?>