The correct Nginx rewrite rules for WordPress are:
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
This sends everything through index.php and keeps the appended query string intact.
If your running PHP-FPM you should also add this before your fastcgi_params as a security measure:
location ~ \.php {
try_files $uri =404;
// fastcgi_param ....
// fastcgi_param ....
fastcgi_pass 127.0.0.1:9000;
}
Related Posts:
- How do I add a server-independent external rewrite rule?
- Using WordPress with Apache behind an nginx reverse proxy
- Why does wordpress still strip my query var?
- Dynamically redirect page based on URL?
- Nginx rewrite rule conflict with WordPress permalinks rule
- Cache issues with redis and nginx
- Change Query String to pretty permalink
- WordPress Redirects When a Query String Contains a Number
- How does WordPress determine if a paged query var is too high?
- Append a value to a certain page’s URL before page load
- Cannot access wp-admin without trailing slash – .htaccess configuration for WordPress behind a nginx proxy
- Retrieve query var within functions.php
- Rewriting / Redirecting request outside wordpress
- Rewrite URL query string for all pages
- Need help with custom rewrite rule
- Using add_rewrite_tag to create urls for page sections
- Change the “page” slug in pagination
- generate_rewrite_rules (action) vs add_rewrite_rule (function): which one is preferred?
- Custom rewrite rules for pages
- Custom permalinks with NextGEN Gallery
- External/non-WP rewrite rules
- Is the SEO plugin necessary?
- How to remove “admin.php?page=” from wp-admin using .htaccess?
- Changing directory and/or URL structure
- How do I add a add_rewrite_rule without it redirecting?
- Blog installed in subdirectory but need to create pages in root. How to use permalinks?
- Pretty URLs or permalinks for attachments
- Why is there /index.php/ in all my links? How do I remove it?
- Taking a value from PHP_URL_PATH won’t work after WordPress 5.5 update
- Server (WordPress) redirects files that are not supposed to (using htaccess)
- Changing WordPress blog name and web address
- htaccess: Remove trailing slash from URL ending with .xml/ only
- Why is WP creating both “/?tag=” and “/tag/” URLS for same content?
- custom url rewrite
- Using Blog Parent Slug on Blog Posts Only
- Regionalised Content
- Custom URL rewrite to specific page template
- Plugin action rewrite rule – non_wp_rules
- WordPress plugin Write User/staff ID as the same as the WordPress User ID
- Map alt domain to specific section of website w/o MU
- Get the category is not working on url
- Using custom mod_rewrite without breaking wordpress permalinks
- How to redirect http://mydomain/blog/blahblah/ to http://mydomain/blahblah/ in wordpress htaccess?
- Append a query string to the end of every URL
- subdirectory install breaking existing links
- Right url for custom post type
- Preserve old website URL structure after migrating to WordPress
- Custom rewrite causes 404 on pagination
- Redirecting /px/?q=x to /px/x/
- Multiple query vars sorting combination and url rewrite
- URL redirect on updating the post date
- WP Rewrite issue
- WordPress keeps writing rewrite rules to .htaccess
- Is it possible to match site root with a WP rewrite rule? [closed]
- How to rewrite AJAX call URL to admin-ajax.php to match REST style URLs
- Add parameter to URL
- Changing URL scheme, mod_rewrite not helping
- Is WordPress API visible from PHP file called in htaccess
- Requested URL changes when using custom rewrite rule
- Insert post ID into the end of a slug preceeded by a dash
- Make Author Archive Page URL be a Subdirectory of a Custom Post Type URL
- Redirect old query string urls to new SEO urls
- Flushing rewrite rules
- Bilingual WP site: How to achieve different URL sturcture rule based on its language?
- How can I create custom URL routes?
- Create custom url which executes code (not render render a WordPress entity)?
- Overwrite WordPress’s URL rewrite not working
- 404 redirect based on url
- Get logged in username in wordpress url
- WordPress 3.1.2 Network Enabled non-www to www
- add_rewrite_rule() issue with parent/child/child page
- Point 404 pages to homepage
- How to customize the Lost Password URL?
- Custom author url and page for another role
- WP permalink working, but why content doesn’t display
- Rewrite query var on postname
- URL rewrite problem in WordPress plugin
- Usw add_rewrite_rule to display frontpage on specific page
- “SAVE PERMALINKS” does more than FLUSH_REWRITE_RULES?
- Rewrite URL to get rid of wp-content etc and change URL
- Rewrite URL for attachments
- How to add gallery slug to attachment url?
- URL Rewriting Per User
- Pagination appearing twice in URL after rewrite
- Rewrite rules goes away
- Redirect if string found in URL
- Rewrite custom taxonomy URL
- Simple URL rewriting gone wrong
- How to turn off searching from URL and go straight to 404 page
- Rewrite URL based on form input
- Getting URL Variables with a Rewritten Page (Login Page)
- What is the proper way to use add_rewrite_rule to remove the (question mark)?
- Custom Rewrite Problem
- WordPress post-type create url rewriting
- help with rewrite_tag and rewrite_rule for custom page GET variables [duplicate]
- Replacing broken urls (dreamweaver) to new ones in wordpress
- How to redirect a virtual page (e.g. /blog) to the home page?
- How do I change my WordPress website’s address or URL?
- Rewrite rule to simulate page hierarchy results in 404
- add_rewrite_rule not working with custom variables