Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

redirect - 404 with Wordpress and GitHub Pages

I have wordpress on the Github pages, what I like to do is to set custom 404 error page created with Wordpress. But every plugin doesnt work for me. I can use any plugin to set custom 404 page, but it will open the default github pages 404 page.

Also I want to create Redirections with Redirection plugin, but it also doesnt work for me it wont open the url I have set, it will open default 404 github page.

I'm using Wordpress 5.6.

Can you help me to solve this problem?

question from:https://stackoverflow.com/questions/65871968/404-with-wordpress-and-github-pages

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

If you want to redirect your Error 404 page, then make a file called "404.html". And paste the code:
<meta http-equiv="refresh" content="0;url=https://new-page-url.com"/>

EDIT:

  • If you want to redirect your Error 404 page to your home page, then paste this code:
    <meta http-equiv="refresh" content="0;url=/">
    Advantages:
    i. One line code.
    ii. You can delay the timing of redirection according to your need by replacing the 0 from the code.
  • And the second one to redirect (used by you,I have excluded the above code) :

<!DOCTYPE html>
<html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <script type="text/javascript">
            window.location.href = "https://zigecek.github.io/error"
        </script>
        <title>Page Redirection</title>
    </head>
    <body>
        If you are not redirected automatically, follow <a href='https://zigecek.github.io/'>this</a>.
    </body>
</html>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...