A query either returns posts or it doesn’t. Whether it’s a non-existent page number, a non-existent category name, a non-existent post name, etc., it’s all the same.
The rewrite rules is matched, which populates the query vars, which forms the query. The query is sent to the database, and the database returns some amount of posts between zero and whatever number was requested.
The only difference between all of those cases is what it does after it’s determined to be a 404, which depends on what rewrite rule was matched. In the case that the name
query var is populated, it tries to find the closest match with an additional LIKE
query, and redirects there if something is found.
Related Posts:
- Why does wordpress still strip my query var?
- Dynamically redirect page based on URL?
- Change Query String to pretty permalink
- Nginx rewrite rules
- WordPress Redirects When a Query String Contains a Number
- Append a value to a certain page’s URL before page load
- Retrieve query var within functions.php
- Rewrite URL query string for all pages
- Need help with custom rewrite rule
- Using add_rewrite_tag to create urls for page sections
- Masking wp-content/themes/name/images to just images directory using htaccess
- Using custom/dynamic “slug” for a page
- How to make pages slug have priority over any other taxonomies like custom-post, post or category
- How do I remove a rewrite rule?
- Use subdomain for certain urls
- Rewrite URL – how to do a SEO-friendly Unicode custom URL?
- Can I call a custom plugin with a direct URL
- Custom slug in front of search URL
- Display posts with author in the url with custom post types
- Clash of the rewrites
- Query Vars for the Homepage?
- Disable wordpress pagination URL rewrite for specific page
- How to use Post Custom Metadata in Post Titles and Post Permalinks
- Using WordPress with Apache behind an nginx reverse proxy
- How do i change the search permanent links
- add_rewrite_rule() not playing nice with child pages
- Custom rewrite rules are sending everything to index.php
- WordPress Network on IIS7/SQL Server – Rewrite Issues
- Custom comments
- How to Change Author Posts URL
- Change permalink for default archive – yearly
- Add .html extension to only one page in my WordPress site
- Migrating a page to be an article
- Multiple Permalinks for Same Post
- How to perform a query at the URL?
- url rewriting for most recent post
- Is there a way to create alias without using htacess, permalinks or delving into code?
- Remove “/page/1” from the URL
- hard flush_rewrite_rules() not regenerating .htaccess
- Use custom template on certain URLs
- Rewrite Rules Are Redirecting and Not Passing VARs
- How to rewrite taxonomy and tags URL
- Changing WordPress Address URL disaster
- Prevent WordPress from Rewriting URL for one template
- Disable Pagination on Pages
- Rewriting a page with a custom parameter
- WordPress 3.9 breaks invalid permalinks.. code fix possible?
- Hide admin login without plugin
- Need help with simple rewrite rule (shouldn’t this be easy?)
- How to add a custom redirect rule for Post as subdomains?
- How to preserve the query string while using add_rewrite_rule and default public query vars
- How do I display only the parent page in the url
- “View post” leads to odd URL
- Redirect HTTP to HTTPS for all sub domains (blog posts)
- Get url param no longer works when using add_rewrite_rule
- How to use add_rewrite_rule in subdomain
- How can I redirect product url to category then product url?
- Map secondary domain to other’s virtual subfolder
- adding custom controller called by front-end
- rewrite attachment url with attachment title
- Rewrite Rules returning wrong data
- htaccess rewrite, adding segment to url
- Custom Download Link
- Adding a query string to only one page url
- force www rewrite if wordpress put in a folder
- Current post ID – relative url
- How to use wp rewrite to hide form action url?
- Custom Structure permalinks error 404
- WordPress Rewrite rule is not working
- change the url in wordpress
- how to move another machine or server without dealing with IP
- change url for portfolio image
- Use URI suffix as parameter and ignore when resolving page
- add_rewrite_rule with optional parameters
- Why wordpress rewrite my custom URL?
- Rewrite rule regex help required
- Redirect empty search to another page
- Rewrite dynamic URLs as pretty URLs in WordPress functions.php (add_rewrite_rule) – what’s wrong with my code?
- WordPress URL redirect and replace ? question mark
- Rewrite rule not working, suspect redirect string
- WordPress index in subdirectory, blogposts in root directory
- Rewrite Url using .htaccess or hook
- url restructure or rewrite having $_GET variables
- How to use a RewriteRule to change endpoint url
- Custom taxonomy Rewrite Rule
- I want to add one extra field to my URLs, I’m using Rewrite functions but it doesn’t work
- .htaccess RewriteRule to include post type and taxonomy
- What’s the best approach to do this?
- Font Page overrides rewrites
- WordPress Rewrite: Ignore Specific Pattern
- WPNetwork with custom URL Rewrite rules
- WordPress index page is returning 404 and admin page requires /index.php in url
- Stop wordpress to redirecting home page if no page found
- Additional .htaccess rules based on wp page
- URL Rewriting in WordPress
- URL rewrites af
- Hide / rewrite download link
- Lost WordPress website access after changing URL [closed]
- Rewrite rule to simulate page hierarchy results in 404
- add_rewrite_rule not working with custom variables