Customize 404 page.

Post Reply
xanmean
Jr. Bludit
Posts: 5
Joined: Tue Jan 29, 2019 7:14 pm

Wed Jan 30, 2019 12:39 pm

How to customize 404 page. Thank you.
User avatar
Edi
Site Admin
Posts: 1363
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Wed Jan 30, 2019 2:24 pm

It's easy:
  • Create a page.
  • Go to "Settings" > "General" > "Advanced" and enter the name of the page in the field "Page not found".
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
User avatar
abdulhalim
Sr. Bludit
Posts: 45
Joined: Thu Mar 10, 2016 6:25 pm

Mon Feb 18, 2019 5:28 pm

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
Jay
Jr. Bludit
Posts: 4
Joined: Mon Feb 11, 2019 8:41 pm

Mon Feb 18, 2019 9:25 pm

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
User avatar
abdulhalim
Sr. Bludit
Posts: 45
Joined: Thu Mar 10, 2016 6:25 pm

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
Jay
Jr. Bludit
Posts: 4
Joined: Mon Feb 11, 2019 8:41 pm

Tue Feb 19, 2019 11:38 pm

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.
User avatar
abdulhalim
Sr. Bludit
Posts: 45
Joined: Thu Mar 10, 2016 6:25 pm

Wed Feb 20, 2019 8:36 am

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
User avatar
Edi
Site Admin
Posts: 1363
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Wed Feb 20, 2019 10:44 pm

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?
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
User avatar
abdulhalim
Sr. Bludit
Posts: 45
Joined: Thu Mar 10, 2016 6:25 pm

Thu Feb 21, 2019 5:15 am

it's a static page, how can I do that? :shock:
User avatar
Edi
Site Admin
Posts: 1363
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Thu Feb 21, 2019 3:46 pm

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 ?>
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
Post Reply