Skip to main content
Share Your Experience: Take the 2024 Developer Survey
31 votes

Changing permalinks gives me 404 errors on nginx

I'm using wordpress multisite with custom permalink setting: /%category%/%postname%/ /etc/nginx/site-available/domain.conf On server{ location / { try_files $uri $uri/ /index.php?q=$uri$args; } ...
Domi's user avatar
  • 411
26 votes

WordPress /page/2 404 pagination problem - what to do?

I had the same problem and I noticed that in the 'posts_per_page = 6' and 'Settings/Reading on 'options-reading' WordPress argument, I was set to 10. When I put everything to the same value (6 in my ...
Jeferson Padilha's user avatar
25 votes

WordPress /page/2 404 pagination problem - what to do?

In my case with custom links: /%category%/%postname%/ I had a problem with: /news/page/2/ And finally this works for me (add to functions.php): function remove_page_from_query_string($query_string) ...
themoonlikeme's user avatar
19 votes

WordPress Migration: Getting 404 Errors: Only Home Page works

Go to settings->permalinks and click on save button to rewrite flush. And then empty your browser cache. It'll work hopefully.
Umer Shoukat's user avatar
17 votes
Accepted

What is This esc_html_e() i wordpress php?

It's a combination of _e(), which echoes a translatable string, and esc_html() which is for outputting text so that the text is not interpreted as HTML. You would use it to prevent HTML being ...
Jacob Peattie's user avatar
16 votes

WordPress /page/2 404 pagination problem - what to do?

Tried several hours, until I found a working solution in this article. In your functions.php file, add /** * Fix pagination on archive pages * After adding a rewrite rule, go to Settings > ...
kregus's user avatar
  • 261
12 votes

Single custom post type page redirecting to 404 page

Newly registered CPT shows 404 because, the register_post_type() doesn't flush the rewrite rules. So it's up to you, whether you want to do it manually or automatically. Manually: Get to /wp-admin/, ...
Mayeenul Islam's user avatar
11 votes

Custom post type single page returns 404 error

Refresh your permalinks. Go to Admin->Settings->Permalinks and hit Save. It refreshes your permalinks and should help, especially if you are changing rewrite ( 'rewrite' => array( 'slug' => ...
Ales's user avatar
  • 211
11 votes

How to prevent automatic redirection of 404 errors and "incorrect" URLs?

As Ash suggested, you can turn off the feature by using the following code: remove_action('template_redirect', 'redirect_canonical'); In looking at the redirect_canonical function in canonical.php, ...
Mike J-P.'s user avatar
  • 211
11 votes

Changing permalinks gives me 404 errors on nginx

Had to add this piece of code to both the /sites-available/your-settings-file and /sites-enabled/your-settings-file: server { [...] if (!-e $request_filename) { rewrite ^.*$ /index.php last; } [...
Angelo Reale's user avatar
9 votes

Wordpress GET parameters causing 404 Not Found

As the OP found out, m is a reserved parameter name that should be use only by core (indicates month). Solution is to use some other parameter name (always use your own prefixes in all global contexts!...
Mark Kaplun's user avatar
  • 23.4k
9 votes
Accepted

WordPress Migration: Getting 404 Errors: Only Home Page works

I found the solution here: https://www.digitalocean.com/community/questions/wordpress-permalinks-not-working-on-ubuntu-14-04 The thing is that we need to allow the override all option in httpd.conf (...
Najeeb's user avatar
  • 353
9 votes

WordPress Migration: Getting 404 Errors: Only Home Page works

Sometimes on a new server it's just the rewrite module missing from Apache config. sudo a2enmod rewrite sudo service apache2 restart
GCL's user avatar
  • 91
8 votes
Accepted

Pagination (page/2/) displaying 404 on archive pages

Found the answer!!! Put this in functions.php (or a required file). Of course, change it to suit your needs. I needed something that only worked for product category archives. function ...
Jordan Carter's user avatar
8 votes

WP Rest API not working

First you've to Check if the WordPress REST API is enabled or not The best way to check is to visit this URL: https://yoursite.com/wp-json. If you see some JSON response, REST API is enabled. If it’s ...
Anand Raja's user avatar
7 votes

Error 404 Page Not Found When Updating a Post or Page

Disable ModSecurity in cPanel Updating and previewing pages/posts were kicking up 404s suddenly on all my websites - but not for all pages and posts (always just the ones I wanted to edit). I went ...
NightL's user avatar
  • 71
7 votes
Accepted

Custom Taxonomy leads to 404 page

You can add flush_rewrite_rules() after registering your custom taxonomy. NOTE: Flush rules only on activation or deactivation, or when you know that the rewrite rules need to be changed. Don't ...
Tunji's user avatar
  • 2,931
7 votes

WordPress Migration: Getting 404 Errors: Only Home Page works

Solved this problem on Linux Mint 19 / PHP Version 7.2.19-0ubuntu0.18.04.1 by changing: <Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted &...
Rajeev Shrestha's user avatar
6 votes

Including category-base in a post permalink results in 404

You only need to add "/." after category base: Category base: news/. (/. is required as it prevents 404s for post). This worked perfectly for me :) EDIT: This field will strip trailing or leading ...
Piotr Markielau's user avatar
6 votes

How to prevent automatic redirection of 404 errors and "incorrect" URLs?

You can disable permalink guessing for 404s without disabling redirection of canonical URLs by adding the following line somewhere in your code (eg. in functions.php): add_filter('...
Ian Mackinnon's user avatar
5 votes
Accepted

Different wordpress 404 template for different post type

WordPress 4.7 introduces a new filter that allows us to easily modify the template hierarchy: /** * Filters the list of template filenames that are searched for when retrieving * a template to use....
birgire's user avatar
  • 67.4k
5 votes
Accepted

Pagination shows 404 after a certain number of pages

The problem is that WordPress is executing the main query before your custom query (and the main query is based on the default post type only). You can intercept the main query, modify it, and then ...
Jared Cobb's user avatar
  • 1,476
5 votes
Accepted

How to open the 404 page in the Theme Customizer preview?

Cool use case. Without any code, in order to load the 404 template, all you have to do is navigate to a non-existent URL on your site. Then, while being logged-in, click the Customize link in the ...
Weston Ruter's user avatar
  • 4,020
5 votes
Accepted

REST API: No route was found matching the URL and request method

It's because of how you've defined the accepted methods: 'methods' => '\WP_REST_Server::CREATABLE ', You shouldn't have quotes around it. WP_REST_Server::CREATABLE is a string that equals 'POST'...
Jacob Peattie's user avatar
5 votes
Accepted

Set a specific page as 404 - not found via my own plugin

You can filter 404_template and return the path of your custom file from the plugin directory like this: add_filter( '404_template', fn() => plugin_dir_path( __FILE__ ) . '404.php' ); ...
fuxia's user avatar
  • 107k
4 votes

How to force a 404 on WordPress

The most robust way I've found of achieving this is to do it in the template_include filter, like so: function wpse91900_force_404(string $template): string { if ($some_condition) { global ...
JacobTheDev's user avatar
  • 1,231
4 votes

Why when I submit a form in wordpress it loads a 404 page though URL is correct

Try to change name="email" to something like name="my_theme_email", do the same with all your field it sounds like some name are reserved with WordPress when sending form data. I got the the same ...
Thierry Edou's user avatar
4 votes

Custom post type single page returns 404 error

You should set the following in your virtualhost apache: <Directory /var/www/html/wordpress> AllowOverride All </Directory> Then, refresh your permalinks: wp-admin->...
Gustavo Siqueira's user avatar
4 votes
Accepted

"Lost password" page triggers 404

Your theme or plugins are most likely modifying the "Lost password" link on your wp-login.php via the lostpassword_url filter. How do I reset the "change password" page to the WP default one? One ...
birgire's user avatar
  • 67.4k
4 votes

Redirect old permalinks with Month and name to Post name on new site

Yoast SEO Redirect Creation tool will allow you to generates the code you need to manually add to your site's .htaccess file to redirect all the posts to the new /%postname%/ structure. Enter your ...
C Sabhar's user avatar
  • 399

Only top scored, non community-wiki answers of a minimum length are eligible