404 error post

When I execute an API through following method, I always get 404 as response code. private void execute() throws IllegalStateException, IOException, NoSuchAlgorithmException { Map<String, ...

When I execute an API through following method, I always get 404 as response code.

private void execute() throws IllegalStateException, IOException, NoSuchAlgorithmException {

    Map<String, String> comment = new HashMap<String, String>();
    comment.put("accounts-groups", "customers/enterprise");
    comment.put("companyType", "customer");
    comment.put("companyName", "Test");
    String json = new GsonBuilder().create().toJson(comment, Map.class);
    Log.i(TAG, "json : "+json);

    HttpResponse response = makeRequest(URL, json);

    /*Checking response */
    if(response != null) {
        InputStream inputStream = response.getEntity().getContent(); //Get the data in the entity
        int statusCode = response.getStatusLine().getStatusCode();
        Log.i(TAG, "statusCode : "+statusCode);
        String result;
        // convert inputstream to string
        if(inputStream != null)
            result = convertStreamToString(inputStream);
        else
            result = "Did not work!";

        Log.i(TAG, "result : "+result);
    }
}

private HttpResponse makeRequest(String uri, String json) throws NoSuchAlgorithmException {
    Log.i(TAG, "uri : "+uri);
    try {
        HttpPost httpPost = new HttpPost(uri);
        httpPost.setEntity(new StringEntity(json, HTTP.UTF_8));

        long timestamp = System.currentTimeMillis();

        String signatureKey = PRIVATE_KEY + timestamp;

        byte[] bytesOfMessage = signatureKey.getBytes(HTTP.UTF_8);

        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] thedigest = md.digest(bytesOfMessage);
        char[] signature = Hex.encodeHex(thedigest);

        String finalSignature = String.valueOf(signature);

        Log.i(TAG, "finalSignature : "+finalSignature);

        httpPost.setHeader("Timestamp", ""+timestamp);
        httpPost.setHeader("Api_token", API_TOKEN);
        httpPost.setHeader("Signature" , finalSignature);

        httpPost.setHeader("Accept", "application/json");
        httpPost.setHeader(HTTP.CONTENT_TYPE, "application/json");          

        return new DefaultHttpClient().execute(httpPost);
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}

I am not getting where am I going wrong. Can anybody please help me out?

Struggling with how to fix the 404 Not Found error on WordPress posts and pages?

This error might appear sometimes when you, or a visitor, try to access a certain page on your site. Instead of seeing the content that you expected, you see something like an “Error 404 Not Found” message instead.

Thankfully, this error message is usually localized to the specific page in question. That is, it shouldn’t affect any other parts of your site (though it can in rare cases).

However, that doesn’t mean it’s not frustrating, and you’ll definitely want to do your best to prevent and fix 404 errors on your site.

In this post, we’ll cover everything that you need to know about 404 errors including:

  • What the 404 Not Found error is and what causes it
  • Fixing sitewide 404 errors on WordPress
  • Fixing individual 404 errors on WordPress
  • Monitoring your site for 404 errors
  • Creating a custom 404 page for your site (this will make more sense after you’ve read the other sections!)

Table Of Contents

  1. What Is Error 404 Not Found?
  2. How to Fix Sitewide 404 Not Found Errors in WordPress
  3. How to Fix Individual 404 Errors on WordPress
  4. How to Monitor Your WordPress Site for 404 Errors
  5. How to Create a Custom 404 Error Page
  6. Fix the WordPress 404 Not Found Error Today

What Is Error 404 Not Found?

The Error 404 Not Found message appears when you, or one of your visitors, tries to visit a page on your site that doesn’t exist.

That could be either because the page never existed, the page was removed (deleted), or the page’s URL was changed to a different URL.

For example, let’s say you have a blog post at yoursite.com/2020-guide. If you update the post for 2021 and change the URL to yoursite.com/2021-guide, then anyone who tried to visit the original 2020-guide URL would see a 404 error because that page no longer exists at that URL (unless you set up a redirect – more on that later!).

Most of the time, the error only appears when a person tries to visit a nonexistent URL on your site. That is, the error won’t affect any content that does exist.

In rare situations, however, a corrupted .htaccess file can cause the 404 error to appear on your entire site.

404 Error Variations

The 404 Error Not Found message can appear in several different variations depending on what web hosting/web server you’re using, the browser that a visitor is using, and how your site is configured.

Here are some common variations:

  • “Error 404”
  • “404 Not Found”
  • “Not Found”
  • “Page Not Found”
  • “The requested URL was not found on this server.”
  • “HTTP Error 404”
  • “We can’t find the page you’re looking for.”
  • “The page cannot be found”

To add some further complexity, it’s actually possible to create your own custom 404 message that will appear whenever there’s a 404 error on your site.

We’ll cover this topic in more depth later on, but this lets you create a more user-friendly error message and help redirect users to the right spot.

For example, on the Astra website, we have a custom 404 page that includes a search box to help users find the content that they’re looking for:

Custom 404 error page Astra

This is actually the default 404 error page for all sites using the Astra theme, though Astra makes it easy to create your own custom design – more on that later too.

Some websites even use their 404 pages as a way to show some creativity, like this 404 page from Ready to Go Survival:

Custom 404 error page 2

Sujay Pawar

Hello! My name is Sujay and I’m CEO of Astra.

We’re on a mission to help small businesses grow online with affordable software products and the education you need to succeed.

Leave a comment below if you want to join the conversation, or click here if you would like personal help or to engage with our team privately.

What Causes Error 404 Not Found?

There are two types of 404 errors that you might be experiencing and the likely cause depends on which type of error it is.

We’ll include fixes for both types of problems below.

If you see a sitewide 404 Not Found error no matter what page you try to visit, the issue is likely with your WordPress site’s permalink structure or .htaccess file.

Something got corrupted somewhere which is causing your site’s server to think your site’s URLs don’t exist. It sounds serious, but this one is usually pretty easy to fix so don’t worry.

On the other hand, if you only see the 404 Not Found error on specific URLs (but the rest of your site works), then there are several potential problems:

  • Broken links – Someone might be linking to a page on your site that doesn’t exist. This could be an external link on someone else’s site or an internal link on your own site. When people click the link, it takes them to a page that doesn’t exist and triggers the 404 error.
  • Changed URLs – If you change the URL of a piece of content, you might have people still trying to visit the old URL which will trigger a 404 error (unless you set up a redirect).
  • Typos – Someone might have accidentally mistyped the URL that they’re trying to visit.

It’s impossible to fix all of these causes because you can’t prevent someone from making a typo.

But you can fix broken links and changed URLs, and you can create a custom 404 page to create a more user-friendly experience for users who make typos.

Why You Need to Fix Error 404 Not Found?

The 404 error can be problematic for a couple of reasons.

The biggest reason is that it’s just plain frustrating for your visitors. They’re trying to access a certain piece of content. Instead of seeing the content they expected, they’re seeing a 404 error instead.

For this reason alone, you should always try to fix 404 errors on your site.

Beyond creating a poor user experience, 404 errors can also be an indirect drag on search engine optimization (SEO). If the 404 error is a result of a broken internal or external link, you might be wasting link equity.

Basically, Google ranks a page in part on how many links point to it. So if a link points to a missing page instead of the actual URL, you’re essentially missing out on the benefit of that link.

Some SEO experts also claim that 404 errors can make it harder for Google to crawl your site, though Google says this isn’t an issue.

How to Fix Sitewide 404 Not Found Errors in WordPress

If you’re seeing the Error 404 Not Found message across your entire WordPress site, you should be able to fix the problem by regenerating your site’s .htaccess file or permalinks.

If you can still access your WordPress dashboard, you can do this directly from your dashboard. Otherwise, you might need to connect to your server using FTP.

Assuming you still have dashboard access, all you need to do is go to Settings → Permalinks in your dashboard.

Then, just click the Save Changes button.

There’s no need to make any other changes – just clicking Save Changes will force WordPress to generate a new .htaccess file, which should fix the problem:

fix sitewide 404 errors

If you can’t access your WordPress dashboard, you’ll first need to connect to your site’s server using FTP with a tool like FileZilla (tutorial here).

Then, delete the existing .htaccess file. We recommend downloading a copy of the file first so that you have a backup just in case.

Once you delete the .htaccess file, you should be able to access your WordPress dashboard and you can generate a new .htaccess file by going to Settings → Permalinks and clicking Save Changes.

How to Fix Individual 404 Errors on WordPress

If you’re experiencing 404 errors on specific pieces of content, you’ll need a more targeted approach to fix the problem.

There are two tactics that you can try:

  1. Fix any broken links on your site to make sure you’re not accidentally sending visitors to content that doesn’t exist.
  2. For remaining errors, you can set up redirects to automatically send people to the correct URL(s) instead of showing a 404 error.

How to Find and Fix Broken Links

The first step in stopping 404 errors is to make sure you don’t have any broken links on your site that send users to a 404 error.

To quickly scan your site for broken links, you can use the free Broken Link Checker plugin.

Once you install and activate the plugin, go to Tools → Broken Links to view a report.

If the plugin detects a broken link, you can fix it directly from the plugin’s interface:

broken link check

Note – while this plugin is useful, we recommend deactivating it once you’re finished to reduce any performance impact from the plugin’s scanning.

How to Set Up Redirects

For any remaining 404 errors, you can fix the problem by manually setting up a redirect to send users to the correct page.

Let’s go back to that example from before where you had a blog post published at yoursite.com/2020-guide and then you updated it for 2021 and changed the URL to yoursite.com/2021-guide.

To prevent people from seeing a 404 error when they visit yoursite.com/2020-guide, you can set up a redirect that automatically redirects the people who visit yoursite.com/2020-guide to yoursite.com/2021-guide.

There are several plugins that make it easy to set up redirects on WordPress, but we recommend the popular and free Redirection plugin.

All you do is enter the original URL and the new destination URL and the plugin will handle everything else for you:

create redirection

To learn more about what redirects are and how to use them, we have a complete guide on WordPress redirects, Or you can check this video to fix 404 errors using redirection.

How to Monitor Your WordPress Site for 404 Errors

If you want to proactively prevent 404 errors on your site, it can be useful to monitor which URLs are triggering them. Then, if you see that a particular URL is causing problems, you can step in and set up a redirect to send users to the proper spot.

There are a few ways that you can track the URLs that are triggering 404 errors:

  • Google Analytics
  • Google Search Console
  • The Redirection plugin

Google Analytics

If you’re using Google Analytics, you can use its built-in reporting to check for URLs that caused 404 errors.

To get started, go to Behavior → Site Content → All Pages and then search for “Page Not Found” with Page Title as the primary dimension:

google analytics 404

You can then click on the result to see the specific URLs that caused the error:

google analytics 404 url

In this example, you can see that yoursite.com/page-that-doesnt-exist was the URL that triggered the 404 error. You can use this information to set up a redirect.

If you’re not using Google Analytics yet, you can follow our guide to add Google Analytics to WordPress or browse the best Google Analytics plugins.

Google Search Console

Google Search Console is another useful way to track 404 errors. Unlike Google Analytics, which tracks the 404 errors that your human visitors encounter, Google Search Console will show the 404 errors that Google’s web crawler bot encounters.

Typically, these errors are the result of broken links, either on your own site or someone else’s site. Or, it could be an issue with your sitemap including content that doesn’t exist.

To look for 404 errors, go to the Coverage report and check for 404 errors in the Type column:

404 errors google search console

Redirection Plugin

For a native WordPress solution to track 404 errors, you can use the free Redirection plugin that we mentioned above. It helps you both track 404 errors and then easily set up redirects for any problems that it finds.

In the setup wizard, make sure to enable the 404 logging feature. Beyond that, there’s nothing else to configure.

You can view a log of 404 errors by going to Tools → Redirection → 404s. If you hover over an error, the plugin will give you an option to set up a redirect right away:

redirection plugin 404 error log

How to Create a Custom 404 Error Page

As we mentioned earlier, another way to lessen the impact of 404 errors is to create your own custom 404 page. You can use your custom 404 page to…

  1. Explain the error and why the visitor isn’t seeing the content that they expected to find.
  2. Include a search box.
  3. Offer some relevant links to your most popular content/features.

There are lots of different ways that you can create a custom 404 page on WordPress – we’ll share three code-free methods.

Astra Theme

If you’re using the Astra theme, you can use Astra’s built-in Custom Layouts feature, which is available in Astra Pro.

Once you activate the Custom Layouts module, you can go to Appearance → Astra Options → Custom Layouts.

Make sure to set the layout as the 404 page and then you can use the native WordPress editor or your favorite page builder to design the 404 page:

astra pro 404 page custom

For a more detailed look, you can follow our guide on how to create a custom 404 page with Astra Custom Layouts.

Elementor Pro

If you’re using Elementor Pro (our review), you can use Elementor Theme Builder to design a custom 404 page template:

Elementor 404 custom page

To learn how to use the Elementor interface, you can follow our Elementor tutorial.

404page

For a free option to create a custom 404 page, you can use the 404page plugin.

To get started, create the design that you want to use for your 404 page using a regular WordPress page (Pages → Add New). You can use the regular WordPress editor or your favorite page builder.

Once you’ve done that, go to Appearance → 404 Error Page and use the drop-down to select the page that you just created:

404page plugin WordPress

That’s it! People who experience a 404 error will now see that page.

Fix the WordPress 404 Not Found Error Today

The Error 404 Not Found message can be frustrating for WordPress users. But with the tactics in this post, you can easily fix your site’s 404 errors and prevent 404 errors in the future.

Beyond that, you can also create your own custom 404 error page that lessens the impact of errors by providing an explanation of what’s going wrong and helping visitors find the content that they’re looking for.

Do you still have any questions about the Error 404 Not Found message on WordPress? Let us know in the comments!

  • Remove From My Forums
  • Question

  • User-539691603 posted

    I created a Post method and when i go to run this method on the Postman, it doesn’t work. 

    Controller:

    [Route("api/[controller]")]
    public class OptOutClientController : Controller
    {
    private IOptOutCreateService optOutCreateService;

    HttpClient httpClient = new HttpClient();

    public OptOutClientController(IOptOutCreateService optOutCreateService)
    {
    this.optOutCreateService = optOutCreateService;
    }

    [HttpPost]
    public async Task<IActionResult> OptOutPostClient([FromBody]OptOutRequest client)
    {
    if (client == null)
    throw new OptOutException( "Favor informar os dados do OptOut!");

    var result = await optOutCreateService.Process(new OptOutCreateCommand(client.Cpf, client.Email, client.Telefone, client.Bandeira, client.Canal));

    return Ok(new ApiReturnItem<OptOutResult> { Item = result, Success = true });
    }

    }

    How can i put a screenshot here? I’m not getting to do this.

    Postman

Answers

  • User475983607 posted

    pnet

    I wrote this code(i’m writting). I’m starting to write this code, then i have nothing, only one controller and some class.

    As I explained several time now..  Echo back the input to verify you’ve correctly formatted the request.

    namespace CoreApi.Controllers
    {
        [Route("api/[controller]")]
        [ApiController]
        public class HomeController : Controller
        {
            [HttpPost]
            public int Postar([FromBody]int teste)
            {
                return teste;
            }
        }
    }

    PostMan Url: https://localhost:44394/api/Home

    Body: 1

    Note the body does NOT contain {«teste» : 1}.

    • Marked as answer by

      Thursday, October 7, 2021 12:00 AM

  • User753101303 posted

    pnet

    Error 404: http://localhost:55522/api/optoutclient/optoutpostclient

    As explained the url is wrong and should not include the action name. You shouldn’t have this any more now.

    pnet

    Error 500: http://localhost:55522/api/optoutclient

    As explained it means you have a server side exception. If you still have this problem you should start from the exact exception message you have (client is likely null but it’s best to always start from an actual error message rather than trying to guess
    from the code).

    • Marked as answer by
      Anonymous
      Thursday, October 7, 2021 12:00 AM

Updated on February 2, 2023

How to fix WordPress error 404 page not found

WordPress 404 Error Page Not Found

Table of Contents [TOC]

  • WordPress 404 Error Page Not Found
    • ⭐ What is the Error 404 Not Found?
    • ⭐ What Causes A WordPress 404 Error?
    • ⭐ Error 404 Not Found Variations
    • ⭐ Negative Impact Of 404 Errors
      • Do 404s Hurt SEO and Rankings of a Website?
    • ⭐ How to Fix Error 404 Page Not Found in WordPress?
    • WordPress 404 Error – Internet Explorer Cannot Display The Webpage
    • “The requested URL was not found on this server
    • Fix WordPress 404 Not Found Error on Local Server
    • How to Create Your Own Error 404 Not Found Page
    • Tools to Check/Monitor 404 Errors WordPress?
    • Like this:
    • Related

Introduction –

Are you getting WordPress 404 Page Not Found Error and “WordPress Site Permalinks Not Working” Error?

The WordPress 404 error occurs when the server cannot find the requested file or page, and the user is directed to a “404 Not Found” error message. It commonly happens when a site is newly migrated to a new host, the permalink structure is changed, there are incorrect file permissions, an incorrect URL is opened, or there is a poorly coded plugin/theme.

To fix the 404 error on WordPress, there are various troubleshooting meathods. These include clearing browser history and cookies, setting up the permalink, restoring the .htaccess file, setting up a 301 redirect, disabling plugins/theme, checking the URL, updating the .php file, and contacting the hosting provider.

Lets talk aboiut these in a detailed way, but before that lets go over the basics for a better understanding.


There can be multiple case scenarios like:

  • Is your WordPress showing 404 page not found error?
  • Showing 404 error after publishing or changing permalinks?
  • WordPress page is not found but it exists?

404 not found error in WordPress depicts that the server fails to locate the requested posts or pages in your site. Such errors may arise unpredictably or can occur after certain adjustments or improvements that are made to the WordPress site. Those improvements can be a theme change, changed permalinks, missing file or directory in WordPress etc.

In this article, you will learn about how to solve the 404 page not found error on your wordpress site and make website content accessible to you. Simply follow the steps mentioned below 🙂

These error messages can arise from many reasons. Often, a WordPress page returning 404 error occur due to the management of the site such as the deletion of a page or an article without any redirection.

The probability of such issues is maximum during the migration or redesign of the website.

This can also happen during the migration or redesigning of a site. In this case, the URLs may have changed or been rewritten and have not been correctly redirected to the new URLs.

Like the 500 internal server error or error establishing database connection. WordPress showing a Error 404 Not Found is another common problem that most WordPress users face at some point.

Other Common WordPress errors

  • WordPress White Screen of Death (WSOD) Error
  • 503 Service Unavailable Error WordPress
  • WordPress HTTP Image Upload Error
  • WordPress File And Folder Permissions Error
  • Pluggable.php File Errors in WordPress
  • Upload: Failed to Write File to Disk” WordPress Error
  • Parse Error: Syntax Error Unexpected in WordPress

Are you encountering frequent website issues?

Our WordPress experts can help you Fix WordPress errors?👍


⭐ What is the Error 404 Not Found?

Who has never faced this problem? You do a search on the Internet from your favorite search engine, Google, Bing, and trust it as to the site on which you will land; or else click on a link from a site you are currently looking at hoping to continue reading or benefit from a product or service and there it is, drama!

The browser displays one of the messages that we saw above or another of the same style: Error 404 page not found or 404 Page Not Found.

⭐ What Causes A WordPress 404 Error?

Some common causes of 404 errors.

  • A mistyped URL.
  • Caching problems.
  • An issue with your Domain Name Server (DNS) settings.
  • WordPress compatibility issues.

If you happen to get this error on the entire site’s content, it is generally because of a problem in WordPress site’s permalinks. Whereas, if you find it on some specific pages, it is most often a result of changing some part of the content’s slug without fixing a redirect.

When this is the case for a page on a website (or any document), it means that the content accessible at the Web address URL you have just accessed does not exist or no longer exists. The difference between the two can sometimes help a user find the right URL if they use common sense.

Let’s take an example, to show that if the message corresponds to content that does not exist – if you really want to access the content – sometimes get there all the same. A few days ago, I was browsing a website that linked to another one (or rather thought it was).

Unfortunately, this link (which would have been much appreciated for the site that received it) started in the following way: http : // www  . In this case (this is not always true) the webmaster was most likely well-intentioned, except that he went too fast.

Result of the webmaster’s mistake, when clicking on the link, the site was obviously inaccessible. Frustrating for the user (in this case here, me) and the webmaster of the site who would have received the link if the latter had been inserted correctly.

As a webmaster, you went too fast in making internal link and in a case like this, you need to correct the link as soon as possible because it may risk losing a very large majority of visitors (and sales who go with it) who are not necessarily going to bother doing what we just mentioned or trying to access your product page (or blog article or other) by another means.

The consequences can be very unfortunate for both the traffic on the site and for the turnover of an online store, you must be vigilant and watch this closely to correct the error 404 as soon as it occurs.

To be able to monitor all this, the Google Search Console will be ideal, and to save time in corrective actions, we strongly advise you to use 404 broken link finder tools mentioned below in this article.

⭐ Error 404 Not Found Variations

Because each web browser displays error messages differently, you might see a different message for this error. Other common variations include:

  • Error 404
  • 404 Not Found
  • HTTP Error 404
  • 404 – file or directory not found. wordpress
  • ERROR 404. PAGE NOT FOUND On WordPress site
  • The requested URL was not found on this server.
  • The page cannot be found
  • We can’t find the page you’re looking for.
  •  the requested url was not found on this server. wordpress

The Error 404 not found message is treated suitably by many sites that fetch a custom page to cover the error and not just show one of the typical messages above.

Therefore, a visitor may not experience the error message at all since many sites rather deploy interesting or creative 404 pages.

404 error is problematic for your users’ experience but also harmful for your SEO positioning.

⭐ Negative Impact Of 404 Errors

More specifically, where a permalink issue is causing sitewide 404 errors, Google crawlers’ wont be able to penetrate through and index the site’s content. Consequently, one should immediately resolve 404 errors. There are a lot of experts out there stating that 404s will ruin your rankings and that you should fix them as soon as possible.

In addition to losing visitors who do not find what they are looking for, are giving negative signals to Google. First, it slows down Google robots, which then give less importance to your site.

In addition, if a page receives good quality external links and it no longer exists, all the popularity of the links is no longer transmitted correctly to the entire site. 404s have an impact on rankings. But not the rankings of a whole site. If a page returns a 404 error code, it means it doesn’t exist, so Google and other search engines will not index it. Pretty simple, right?

Do 404s Hurt SEO and Rankings of a Website?

You can discover 404 errors in Google Search Console or by installing a third-party plugin like Redirection which lists 404 errors.

If a user arrives on a page of a site with a 404 error via an internal link, an external link or even via social networks, he will be frustrated not being able to access the content he wanted to see.

This can give an unprofessional image to a brand and cause a future rejection on the part of the Internet user who will remember this bad experience.

⭐ How to Fix Error 404 Page Not Found in WordPress?

Because this error discloses inconsistency with a link, it can typically resolve the same by properly configuring and saving WordPress permalinks. You should also correct the linking structure using a .htaccess file.

1. Save Permalinks

It is a simple solution to fix 404 error in WordPress by saving WordPress permalinks. This will update .htaccess file with the correct configurations for WordPress website.

To save permalinks, login to WP dashboard and go to Settings > Permalinks.

how to fix wordpress posts returning 404 error

Then, scroll down and click on Save Changes.

fix error 404 not found on wordpress site

Now try accessing the posts to see if the 404 error is fixed.

2. Manually Reset Permalinks

If saving the permalinks did not solve the 404 issues, then you can manually reset permalinks by editing the .htaccess file.

To do this, access WordPress files using FTP. When connected via FTP, locate .htaccess file and edit it.

wordpress 404 error after changing permalinksAdd in one of the following codes, save, and upload the updated file to your server:

A) When WordPress Site in the Main Domain

If site is on the main domain, e.g. www.yoursite.com, add this code to .htaccess file:

# BEGIN WordPress
 <IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /
 RewriteRule ^index.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /index.php [L]
 </IfModule>
 # END WordPress

After editing and uploading a new file, refresh your site and access posts/pages to see if this fixes the 404 issues.

B) If WordPress Site in a Subdomain

If your site is installed in a subdomain, such as blog.yoursite.com, use this code instead.

RewriteEngine On
 RewriteBase /
 RewriteRule ^index.php$ - [L]
 RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^ - [L]
 RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
 RewriteRule ^(.*.php)$ $1 [L]
 RewriteRule . index.php [L]

C) When WordPress in subdirectory

If your site is on a subdirectory, such as www.yoursite.com/blog, edit .htaccess to include this code instead.

RewriteEngine On
 RewriteBase /
 RewriteRule ^index.php$ - [L]
 RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
 RewriteCond %{REQUEST_FILENAME} -f [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^ - [L]
 RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
 RewriteRule ^([_0-9a-zA-Z-]+/)?(.*.php)$ $2 [L]
 RewriteRule . index.php [L]

3. Set Up 301 Redirects for Moved or Renamed Content

The 301 redirect is the most effective solution for correcting 404 errors on your site. However, it must be done correctly, making sure to redirect to the right pages as appropriate:

  • The page with error 404 has been replaced on the site by a new page which has a different URL: We are redirecting directly to this new page.
  • The page with error 404 has not been replaced on the site: We are redirecting to a page with similar content. If no similar content exists, it is also possible to redirect to the category page of the old content. As a last resort, redirect to the home page (Do not do this systematically).
  • Before deleting a page and redirecting, be sure to check if it has backlinks (external links), visits and if it is still well-positioned in Google.

To begin, you can take the help of a free Redirection plugin to fix redirects from your WordPress dashboard. After installing and configuring the plugin, visit the “Tools” menu and select “Redirection” and then type the 404 page URL in the “Source URL” box and the new working URL in the “Target URL” box.

how to fix wordpress error 404 page not found

If you use a CMS like WordPress, it is possible to use a plugin like this one. It allows automatic redirection by indicating the old and the new URL without going through the .htaccess file.

Implementing 301 Redirects Manually

Manually in the .htaccess of your hosting panel, using the piece of code:

  • To 301 Redirect a Page:

RedirectPermanent /old-file.html http:// www.domain.com/new-file.html

  • To 301 Redirect an Entire Domain:

RedirectPermanent / http:// www.new-domain.com/

Once you have inserted the commands to 301 redirect your pages, you need to make sure that there is a blank line at the end of the file. Your server will read the .htaccess file line by line, which means you need to throw an “end line” character to signify that you’re finished. An easy way to do this is to put a blank line at the bottom of the file.

Now that you’ve cleaned up your 404 errors, you can now anticipate this type of problem by creating a well-designed custom 404 page. You can in particular take inspiration from Google which offers creations all more original than the others.

Edit .htaccess

You need to edit the .htaccess file (and add a snippet of code at the top) which can be done in a number of ways. You can either get it done through an FTP program’s edit mode or edit the file on your PC and then upload it to the server via FTP or you can do this via cPanel >> File Manager.

This is the code:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# End WordPress

WordPress 404 Error – Internet Explorer Cannot Display The Webpage

Sometimes your WordPress website works fine on other web browsers, except Internet Explorer. Indeed, IE ignores the 404 conditions since the dawn of IE.

However, a few weeks ago, Microsoft introduced a system update for IE7 and IE8 which can cause the 404 error to stop immediately on your website, even if your website returns valid content.

troubleshoot-and-fix-wordpress-404-error

The solution is simple. You will have to put the code in header.php which is located in your theme folder.

header(‘HTTP/1.1 200 OK’);

“The requested URL was not found on this server

Changing and Update WordPress Url in Database

Let’s assume you encounter the below error on your WordPress website.

“The requested URL was not found on this server. If you entered the URL manually, please check your spelling and try again.”

wordpress 404 page not showing

In such a scenario, visit your PHPMyAdmin, then locate your database name and select wp-option, e.g. blog → wp-option.

404 file or directory not found wordpress

Now change the URL like your website URL is https://www.abc.com/blog/ replace it to http://localhost/blog.

wordpress page not found but it exists

Related Read How to Backup WordPress Database Manually?

Fix WordPress 404 Not Found Error on Local Server

At the staging level, quite a few developers and designers install WordPress on their desktops and laptops by running a local server. To that effect, a general problem arises with using WordPress on a local server is that they find it difficult to get permalink rewrite rules to give desired results.

Despite fixing fix the permalinks for posts and pages, the website still shows the “404 Not Found” error.

error 404 not found - what does it mean & how to fix it

In this situation, you need to turn on the rewrite module in your WAMP, XAMPP, or MAMP installation.

Navigate to the taskbar and find the WAMP icon. After that navigate to Apache → Apache modules.

what is error 404 not found

It will enable a long list of modules that you can toggle on and off. Find the one called “rewrite_module” and click it so that it is checked.

how to fix 404 page not found error in wordpress

Then check out your permalinks again.

How to Create Your Own Error 404 Not Found Page

While you can do your best to prevent 404 errors by following the tips above, it’s impossible to entirely eliminate 404 errors because some things are just plain outside your control. It’s not uncommon for small WordPress sites to have thousands of 404 errors every month.

To provide a more user-friendly error page, you can use one of the many 404 page plugins. For example, the free 404 page plugin lets you set up a custom 404 error page with:

  • A search box
  • Important links
  • Contact information

But remember, keep your 404 page light for better performance.

Related Read – List Of WordPress Website Maintenance Tasks

Tools to Check/Monitor 404 Errors WordPress?

Adopting a foresighted approach, it’s crucial to analyze which requests are resulting in 404 errors at your site. This helps you in:

  • Find broken links that are directing visitors to a page or a site that is unavailable. Eventually, you can take all remedial steps to fix such broken links.
  • Understand which pages or pieces of content have difficulty, coming in the preview of Google crawlers. Then you can make necessary corrections primarily by setting up a redirect.
  • Troubleshoot issues and improve performance with regard to 404 errors.

Use WordPress Plugin

If you want to use a WordPress plugin, the aforementioned Redirection plugin can help you monitor for 404 errors from your WordPress dashboard.

 Use 404 error broken link checking Tools

You can also use a third-party audit tool like Ahrefs to monitor for 404 errors on your WordPress site. You can even set this up to run on a schedule.

Check every link on your website to determine whether the link leads to a 404 error using tools for checking broken links is the broken link crawl (or scan) tool.

Crawl tools:

  • Screaming Frog
  • SiteLiner,
  • SiteBulb

Use Analytics Tools

For example, you could trigger the following event onload of the error page:

ga('send', 'event', 'error', '404', location.pathname);

With the help of Google Analytics, you can set up a custom report to track 404 errors from external links.

Use Free broken link checker / dead links tools

  •  error404.atomseo  – A free web-based online tool for checking broken or dead links (404 errors)
  • Dead Link Checker: Free Broken Link Checking Tool
  • Brokenlinkcheck – Free Broken Link Checker Dead Link Checking Tool
  • chrome.google.com/webstore/detail/broken-link-checker/ –  find all broken links (404 errors) on the web page
  • Dr. Link Check: Broken Link Checker
  • Hexometer – Broken Links Scanner for 404 or Dead links

Find 404 error pages using search console google

Google Search Console is often used less. However, lastly, you can track 404 errors along with other important information about your site and its referencing is indicated there. Just go to Crawl → Crawl Errors, -Not found, to view a list of 404 errors that Google has encountered. This can also in particular help you to improve the user experience and the visibility of your website.

Find-404-pages-using-search-console-google

In most cases these solutions will fix the WordPress posts 404 error. However, if it does not work for you, then you may probably need help.


Get in touch with our team of WordPress Experts To Solve Errors on Your WordPress Site.


Other Useful Articles (In-Depth)

  • Fix This account has been suspended wordpress issue
  • How to disable directory listing in wordpress
  • WordPress hacked redirecting to another site how to clean it
  • How To Fix hacked Godaddy hosted site
  • Fix Japanese Keywords hack In WordPress Site
  • How to Remove Blackhat SEO Spam in WordPress Site?

WordPress is a powerful CMS. Sometimes a slight tweak can make your website inaccessible. However, finding a solution for any WordPress problem is extremely easy (check out how to properly ask for WordPress support and get it). In the past we have covered some of the most common problems WordPress users face. Like the internal server error or error establishing database connection. Another common problem that most WordPress users face at some point is WordPress posts returning a 404 Error. In this article we will show you how to fix WordPress posts returning 404 error.

Fixing WordPress posts returning 404 error

Usually in this scenario a user can access their WordPress admin area, their blog’s main page, but when accessing a single posts they get a 404 Not found error. First of all, don’t panic most of the time your posts are still there and completely safe. This usually happens if your .htaccess file got deleted or something went wrong with the rewrite rules. What you need to do is fix your permalinks settings.

Video Tutorial

Subscribe to WPBeginner

If you don’t like the video or need more instructions, then continue reading.

Go to Settings » Permalinks, and simply click on Save Changes button.

Update permalink settings

This will update your permalinks settings and flush rewrite rules. In most cases this solution fixes the WordPress posts 404 error. However, if it does not work for you, then you probably need to update your .htaccess file manually.

Login to your server using FTP, and modify the .htaccess file which is located in the same location where folders like /wp-content/ and /wp-includes/ are located. The easiest thing you can do is to temporarily make the file writeable by changing the permissions to 666. Then repeat the original solution. Don’t forget to change the permissions back to 660. You can also manually add this code in your .htaccess file:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Fix for Local Servers

Often designers and developers install WordPress on their computers using a local server for testing purposes. If you want to use pretty permalinks, then you need to enable the rewrite_module in the Apache configuration of your MAMP, WAMP, or XXAMP.

We hope this article helped you resolve posts returning 404 error in WordPress. Did this solution work for you? Do you have another solution that worked for you? Please share it in the comments below. We would like to make this article a comprehensive resource for users who run into this issue.

Disclosure: Our content is reader-supported. This means if you click on some of our links, then we may earn a commission. See how WPBeginner is funded, why it matters, and how you can support us.

Editorial Staff

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. We have been creating WordPress tutorials since 2009, and WPBeginner has become the largest free WordPress resource site in the industry.

Reader Interactions

It is common that you come across the WordPress 404 or “WordPress site permalinks not working” error on your website if it is not appropriately maintained. But there are times when your website is under maintenance, and your visitors will be automatically directed to a 404 error page.

Are you facing a WordPress 404 error or a “WordPress page not found” error? Don’t freak out! We have a solution for you.

  • What is a WordPress 404 Error?
  • How to Fix 404 Error on WordPress (8 Solutions)
    1. Clear the Browsing Cache and Cookies
    2. Set Your Permalinks
    3. Restore Your .htaccess file
    4. Set Up a 301 Redirect
    5. Disabling Plugins/Themes
    6. Change and Update WordPress URL in Database
    7. Fix WordPress 404 Error on Local Servers
    8. Alternative Method
  • Conclusion

What is a WordPress 404 Error?

The 404 error is an HTTP response code that occurs when the server cannot find the file or page requested by the user. In response, the web hosting server automatically sends the user an error message, “404 Not Found“.

The WordPress 404 error commonly occurs when:

  • You’ve newly migrated your site to a new host.
  • You have changed your URL’s permalink structure and haven’t redirected the old URL.
  • You don’t have file permissions.
  • You have opened an incorrect URL.
  • Poorly coded plugin/theme.

Many WordPress themes offer creative layouts & content options to display the 404 error page. Cloudways’ 404 error has a custom design and layout too:

404 error

Managed WordPress Hosting Starting from $10/month.

Enjoy hassle-free hosting on a cloud platform with guaranteed performance boosts.

How to Fix 404 Error on WordPress (8 Troubleshooting Solutions)

This tutorial will show you how to quickly fix the 404 Not Found status code. So let’s get started!

1. Clear Browser History & Cookies

The first troubleshooting method you should try is clearing the browser cache and cookies. Or you can try to visit your site in incognito mode.

2. Set Up Your Permalink

If apart from your homepage, your other WordPress website pages give you a 404 page not found error, you can update your permalink settings by following the steps below:

  • Log in to your WordPress Dashboard.
  • Go to SettingsPermalinks.
  • Select the Default settings.
  • Click the Save Changes button.
  • Change the settings to the previous configuration (the one you selected before Default). Put the custom structure back if you had one.
  • Click Save Settings.

Note: If you use a custom structure, copy/paste it into the Custom Base section.

custom structure setting

This solution could fix the WordPress 404 not found or “WordPress permalinks not working” error.

If it doesn’t work, you’ll need to edit the .htaccess file in the main directory of your WordPress installation (where the main index.php file resides). 404 errors are also usually due to misconfigured .htaccess files or file permission-related issues.

3. Restore Your .httaccess File

Since .htaccess is a hidden file, you must set all files as visible in your FTP.

Note: It’s always recommended to backup your site before editing any files or pages.

Follow the steps below:

  • Log in to your server using an FTP client.
  • Download the .htaccess file which is located in the same location as folders like /wp-content/ wp-admin /wp-includes/.
  • Open the downloaded file in any text editor.
  • Visit the WordPress .htaccess support page and copy/paste the version of the code that is most suitable for your website.
  • Save the .htaccess file and upload it to the live server.

public folder

For example, if you have Basic WP, use the code below.

# BEGIN WordPress

RewriteEngine On

RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

RewriteBase /

RewriteRule ^index.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /index.php [L]

# END WordPress

4. Setup a 301 Redirect

If you have changed the URL of any specific page and haven’t redirected it yet, it’s time to redirect the old URL to your new URL. You may redirect your old post/page via a plugin or a .htaccess file.

If you are comfortable working with .htaccess, add the following code to your .htaccess file. Don’t forget to replace the URLs with your own website.

Redirect 301 /oldpage.html https://www.mywebsite.com/newpage.html

If you prefer the easy way, you may use a plugin to set up a 301 redirect. Follow the steps below:

  • Install the Redirection Plugin.
  • Go to the WordPress Dashboard.
  • Click Tools > Redirection.
  • Complete the setup and Add new redirection.

Redirection via plugin

5. Disabling Plugins/Theme

An outdated or poorly coded plugin may be causing the 404 error on your WordPress site. To check this, you must deactivate all your plugins and change your current theme.

Note: All WordPress themes have 404.php files but don’t necessarily have a custom 404 error template file. WordPress automatically uses the 404.php page if the 404 error occurs. 

You may access your WordPress files using an FTP like FileZilla. Go to public_html > wp-content and change the plugins folder name to something like myplugins.

Disabling Plugins

Now go back to your browser to check whether the website is working. If the error has been resolved, then any of your plugins could be the culprit.

Note: If it’s not resolved, simply change the myplugins folder name to plugins and move to the next troubleshooting method.

If it’s resolved, change the myplugins folder name to plugins and follow the steps below to check which of your plugin(s) is causing the error.

  • Go to your WordPress dashboard.
  • Go to Plugins > Installed Plugins.
  • Activate each plugin one by one and check if your website is working.
  • When you encounter the 404 error, you’d know which plugin caused it.
  • Update the plugin or remove it to get rid of the error.

WordPress plugins

6. Change and Update WordPress URL in Database

You might encounter the following error message on your WordPress website.

“The requested URL was not found on this server. If you entered the URL manually, please check your spelling and try again.”

Update WordPress URL

Fix the error by following the steps below:

  • Go to your PHPMyAdmin.
  • Navigate to your database name, and select wp-option. For example, blog > wp-option.

PHPMyAdmin

  • Change the URL, for example, from https://www.abc.com/blog/ to http://localhost/blog.

change the URL

7. Fix WordPress 404 Error on Local Servers

Many designers and developers install WordPress on their desktops and laptops using a local server for staging purposes. A common problem with local server installations of WordPress is the inability to get permalink rewrite rules to work.

You may try to change the permalinks for posts and pages, but eventually, the website shows the WordPress “404 Not Found” error.

Fixing Errors is Easier With Cloudways

Get rid of WordPress errors with a cloud hosting built to deliver a hassle-free experience with incredible speeds.

Start Free!

In this situation, turn on the rewrite module in your WAMP, XAMPP, or MAMP installation. I am using WAMP in this tutorial. Navigate to the taskbar and find the WAMP icon. After that, navigate to ApacheApache modules.

Fixing Errors

It will enable a long list of modules that you can toggle on and off. Find the one called “rewrite_module” and click it, so it is checked.

apache

Then check whether your permalinks are working or not.

8. Alternative Method

If none of the above solutions work, you may try the alternative method to fix the 404 error.

  • Navigate to the local server.
  • Find the Apache folder, then go to the “conf” folder.
  • Navigate to the httpd.conf file.
  • Search for a line that looks like:

#LoadModule rewrite_module modules/mod_rewrite.so

  • Remove the “#” sign so it looks like this:

LoadModule rewrite_module modules/mod_rewrite.so

Additional tip: PHP workers are used while executing your WordPress site’s code. An ecommerce site that gets 50,000 visitors per month needs a lot more resources than a simple blog with the same amount of traffic.

Conclusion

I hope this guide helped you solve the “WordPress 404 page error” or “WordPress permalinks not working” problem. Have you figured out any other ways to get rid of this problem? Please share your solutions with us in the comment section below.

Also, if you are a WordPress user and want to boost your site, you must try Cloudways WordPress hosting solutions and take advantage of its 3-day free trial.

Frequently Asked Questions

Q. Why am I getting a 404 error?

WordPress 404 errors usually occur when you have removed certain pages from your website and haven’t redirected them to your live pages. Sometimes, these errors may also occur when you have changed a URL of a specific page.

Q. How do I test a 404 error?

You can use multiple tools to test WordPress 404 errors, like Deadlinkchecker. Or you may access Google Analytics to find out which blogs are giving you a 404 error.

Q. How do I fix error 404 on WordPress?

You can fix the error 404 on WordPress by implementing the following solutions:

  • Clear the browser cache and cookies
  • Set your permalinks
  • Make a default .htaccess file
  • Set up a 301 redirect
  • Disable plugins and themes
  • Change and update the WordPress URL in the database
  • Fix the error on local servers

Q. How to redirect WordPress 404 pages?

Follow the steps below to redirect WordPress 404 pages:

  • Go to your WordPress dashboard.
  • Navigate to Tools > Redirection.
  • Apply redirection by pasting the broken URL in the source box and the new URL in the Target box.

Q. How to edit a WordPress 404 page?

You may edit a WordPress 404 page by following the steps below:

  • Visit your WordPress dashboard.
  • Navigate to Appearance > Theme Editor.
  • Find the file named “404.php file” and edit the file yourself or with the help of a WordPress developer.

If you have been trying to submit a form in WordPress and you are receiving a 404 error page, well the chances of the cause being using a reserved keyword can be extremely high. This is because one or many of your field name  is being reserved by WordPress.

submitting form as a POST request displays 404 in WordPress

In the below snippet, name=”calendar”  is a reserved word. Submitting the form will display the bad 404 page. In-order to avoid we can prefix it name=”mytheme_calendar” or ensure that the variables we use are not reserved by WordPress?

<form action="<?php the_permalink();?>" method="post">
        <label>Calendar</label>
        <input type="text" name="calendar"/>
    <input type="submit" value="Submit" name="qwe" value="submit" />
</form>

What do you mean “Reserved by WordPress” and “What are the keywords being reserved” ?

The following keywords or terms are being used by WordPress for important operations as a result, WordPress prevents you from using them. If you have been following WordPress best practices, you wouldn’t encounter an issue as it is a good practice to prefix every variable with a unique prefix word. This not only avoids conflict with WordPress but with other plugins and themes

  • attachment
  • attachment_id
  • author
  • author_name
  • calendar
  • cat
  • category
  • category__and
  • category__in
  • category__not_in
  • category_name
  • comments_per_page
  • comments_popup
  • custom
  • customize_messenger_channel
  • customized
  • cpage
  • day
  • debug
  • embed
  • error
  • exact
  • feed
  • hour
  • link_category
  • m
  • minute
  • monthnum
  • more
  • name
  • nav_menu
  • nonce
  • nopaging
  • offset
  • order
  • orderby
  • p
  • page
  • page_id
  • paged
  • pagename
  • pb
  • perm
  • post
  • post__in
  • post__not_in
  • post_format
  • post_mime_type
  • post_status
  • post_tag
  • post_type
  • posts
  • posts_per_archive_page
  • posts_per_page
  • preview
  • robots
  • s
  • search
  • second
  • sentence
  • showposts
  • static
  • subpost
  • subpost_id
  • tag
  • tag__and
  • tag__in
  • tag__not_in
  • tag_id
  • tag_slug__and
  • tag_slug__in
  • taxonomy
  • tb
  • term
  • terms
  • theme
  • title
  • type
  • w
  • withcomments
  • withoutcomments
  • year

 If you think that this is not causing the issue, leave a comment and will help you out. WordPress is an interesting CMS and while developing themes and plugins you might come across several issues. We always recommend reading WordPress guide   . It covers guides for both Beginners and Intermediates.

I’m a passionate engineer based in London.
Currently, I’m working as a Cloud Consultant at Contino.

Aside my full time job, I either work on my own startup projects or you will see me in a HIIT class 🙂

Понравилась статья? Поделить с друзьями:

Читайте также:

  • 404 error img
  • 404 error icon png
  • 404 error file not found gta 5 rp
  • 404 error example
  • 404 error bones текст

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии