How to fix WordPress 404 Not Found error using .htaccess file or Nginx configuration. Ensure that the URLs on your website are functioning correctly. The 404 error code is frequently encountered on newly installed websites on hosting and in the process of using WordPress. This error appears when the browser cannot find the Wordpress website or the specific resource requested by the user. It is usually displayed as a “404 Not Found” error message.
How to Fix WordPress 404 Not Found Error for Posts and Pages
404 errors can be frustrating for users and affect the browsing experience. In this article, we will learn the cause and how to fix, fix 404 wordpress error with .htaccess file or Nginx configuration. Make sure that the URLs on your site work correctly.
Some causes of 404 Not Found error in wordpress
There are several main causes of 404 errors in WordPress. Here are some common causes:
- Permalink structure: If you change the permalink structure in WordPress without updating the old links, this can lead to 404 errors for pages and posts that already exist.
- Plugin interaction errors: Some plugins can cause conflicts or errors that cause the site to display a 404 error.
- Missing URL Rewrite configuration in .htaccess file (Apache) or missing Nginx configuration.
How to fix 404 not found error for website using WordPress
Step 1: Check the .htaccess file to fix 404 wordpress error
The .htaccess file is a configuration file for the Apache web server (usually hosting). It is used to define directory-specific rules and directives. The .htaccess file is usually located in the root directory containing the website source code.
If the configuration is missing, the website’s URL will contain “index.php” (like: https://itsmeit.co/index.php/url-bai-viet/), causing 404 errors because of the above article links front end does not include “index.php”.
So to fix the wordpress 404 error, the WordPress page not found error, check the .htaccess file in the directory containing your source code, the Rewrite URL code exists or not. If not, create a .htaccess file and add the following code:
# 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 saving the .htaccess file, clear the wordpress site cache if any and check if the article URLs work as expected. If the 404 error still exists, continue reading the next steps.
Step 2: Check URL Rewrite in Nginx configuration
If you are using the Nginx server, you can open the domain configuration file and add the following code for configuring URL rewriting for WordPress. Make sure to include this code within the appropriate server {} block.
location / { try_files $uri $uri/ /index.php?$args; }
Then restart Nginx and check if the URLs are working properly.
Step 3: Check the URL structure (Permalink)
Check the URL again: Make sure you entered the correct URL. Check for any typos or invalid special characters in the URL. If necessary, edit the URL to make sure it’s correct.
Check the permalink structure: In case you have changed the permalink structure, make sure you have updated the old links to match the new structure. This can be done through WordPress settings under “Settings -> Permalink -> Save Changes”. It will help you to troubleshoot and fix WordPress 404 not found that you are facing.
Those are some steps to troubleshoot and fix WordPress 404 not found errors when using WordPress, helping you to ensure that the URLs and resources on your site can be found correctly. If, after performing the above steps, the 404 not found WordPress page error is still not resolved, consider checking other plugins, themes, or server configurations that may be causing the error. If still unable to resolve, you can seek support from the WordPress community or your hosting/VPS provider for expert help.
– Advertising –