Due to the special characteristics of the 404 error page, people often ignore it and have never thought about designing it. In fact, the 404 error page may mean that the user leaves or continues to browse your webpage. If your 404 page is too monotonous and boring, visitors may not want to browse it; however, if your 404 error page is personalized and friendly, it is likely to attract visitors to other pages on your page.
What is the 404 error page?
Most of the time, you create a website and perform multiple checks to ensure that each link is valid. However, over time, you may forget to point a link to a deleted page, a page with a name changed, or a name changed. Or if a visitor finds your webpage through the search engine but cannot link to it, the page will jump to the 404 error page. Generally, a wordpress topic contains 404.php. you do not need to design one independently. If you do not have one or want to have a personalized and creative 404 error page, you can design it separately.
Error 404: a 404 Error page is a page returned when a user uses a search engine or directly opens a link that does not exist. The 404 error page has a special significance: To report a message to the viewer that the requested page does not exist or the link is incorrect. At the same time, the user is guided to browse other pages of the website rather than leaving directly.
Basic 404.php
Generally, wordpress Themes contain 404.php, except for some. WordPress is set to automatically search for the 404. php file when a page error occurs by default. If the file does not exist, the browser will display annoying error messages. It may even have a negative impact on the SEO of your blog. If your blog topic does not have this file. You can create a new blank File by yourself and name it 404.php. below is the most basic 404. php code: 404.php File
<? Php get_header ();?> <H2> Error 404-Page Not Found.
404. The basic php code includes H2 tags -- "Error 404-Page Not Found", instructions for reading headers, sidebar, and footer. Of course, you can adjust the code as needed to adapt to the template and style of your blog.
We will take several steps to break down and modify the 404. php tutorial. Please note that I always use the get_header, get_sidebar, and get_footer commands to call the wordpress theme file. You should slightly modify the 404. php file as needed to adapt to your topic.
Start modifying the 404 error page
First, we will add the search code on the 404 error page, so that the 404 error page will not be too monotonous and lacks the operation options. If a visitor browses your 404 page, he can search your other pages in the search box. This is a way to help you retain visitors.
Add search code for 404.php
<? Php get_header ();?> <H2> Error 404-Page Not Found.
Error page of idea 404
Create an innovative 404 error page to allow viewers to stay on the error message for a short time and then redirect them to your homepage. 404 error pages can be as friendly as possible to achieve search engine optimization. Edit the header. php file in the template. In your header. php meta tags on the top, you can add the following code:
<? Php if (is_404 () {$ redirectHome = get_option (home);?> <? Php echo $ redirectHome;?>
Then add the red code in 404. php:
404. php File
<? Php get_header ();?> <H1> Error 404-File Not Found.
The above example is used to guide visitors from the 404 error page to the website homepage. This will also help websites retain users, rather than making them confused and finally leaving. This example may not always be the best solution, but it is very effective for visitors to search for the content on your website.
Make sure that the 404 error page can work
You can enter a page that does not exist on your webpage to check whether the 404 error page is valid. (The red part is your home address) for example: http://www.yourwebsitedomain.com/test404page.php
This will open your 404 error page. If not, the test fails.
If the test fails
If your server does not automatically open 404.php, you can obtain support by modifying. htaccess. Find the. htaccess file at the wordpress installation address and add the following code:
ErrorDocument 404/index. php? Error = 404.
If your wordpress is not installed in the ftp root directory but in the ftp sub-folder, you must change the. htaccess file to: (YOURSUBFOLDERNAME, the name of the sub-folder)
ErrorDocument 404/YOURSUBFOLDERNAME/index. php? Error = 404.
In this way, your 404. php file will be called. The following is a complete example of code. We will teach you how to use 404. php to help you find what you are looking. Feed back some information to them as much as possible to attract them to continue browsing other pages.
<? Php get_header ();?> <H1> 404 Error