Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k 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 Reply

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...