Direct quote from Pitfalls and Common Mistakes: Taxing Rewrites:
By using the return directive we can completely avoid evaluation of regular expression.
Please use return
instead of rewrite
for permanent redirects. Here’s my approach to this use-case…
location = /content/unique-page-name {
return 301 /new-name/unique-page-name;
}
Related Posts:
- Nginx Redirect via Proxy, Rewrite and Preserve URL
- Remove “www” and redirect to “https” with nginx
- How can I use environment variables in Nginx.conf
- “413 Request Entity Too Large” in Nginx with “client_max_body_size” set
- Nginx: Failed to start A high performance web server and a reverse proxy server
- NGINX: upstream timed out (110: Connection timed out) while reading response header from upstream
- How to fix nginx throws 400 bad request headers on any header testing tools?
- How to use NGINX as forward proxy for any requested location?
- “configuration file /etc/nginx/nginx.conf test failed”: How do I know why this happened?
- nginx – two subdomain configuration
- GeoIP.dat.gz and GeoLiteCity.dat.gz not longer available? Getting 404 trying to load it
- wp-json/ return 404, but wp-json/wp/v2/ works fine on my nginx server
- ERR_TOO_MANY_REDIRECTS status 302, how to configure NGINX locations to work with AWS ALB?
- NGINX conf on WP Multisite enabled — subdirectory — images fail to load after updates
- Configuring Routing Rules for WordPress+Nginx and WP-SuperCache?
- Installation failed: Could not create directory – CentOS 7
- REST API parameters not working with nginx
- Difference between these two nginx try_files statements for WordPress?
- How to test drive WordPress on VPS with LEMP stack before going live?
- nginx.conf appeared in all WordPress installations on folder
- nginx php-fpm, and auto updates?
- WordPress and nginx, download some pages instead of serving them
- nginx wordpress subdirectory Invalid post type
- Nginx + Redirection Plugin breaks Permalinks [closed]
- ERROR: No such service: nginx when building wordpress with docker [closed]
- Nginx tries the wrong file when http_cookie matches logged_in
- Site resolves to www in Firefox and without in Chrome
- WordPress Nginx Won’t 404
- WordPress file not found and 403 forbidden
- Correct regex for Nginx FastCGI cache?
- Random occurences of 502 Bad Gateway using WordPress and Nginx
- SSL via different domain & path with NGINX/PHP-FPM/WP
- Limit file downloads to logged in users (WP + Nginx)
- /blog/wp-json/ nginx return 404
- WordPress with Photocrati Theme keeps resetting site URL – help solving underlying problem
- NGINX / WordPress Site – Increasing php.ini max_execution_time = 600 doesn’t work
- Nginx redirects to an extra subdirectory
- Something is injecting a slash after any static file response , server is nginx
- Custom permalinks not work on Nginx + Apache
- Last-Modified header is removed from server response!
- Do I need a DNS on a home network?
- 504 Gateway Time-out nginx/1.14.0 (Ubuntu)
- WordPress + Nginx (Lightsail) problem with ajax
- Can I do fragment caching with NGINX fastcgi?
- Proxy caching WordPress with Nginx
- How to configure nginx for wordpress
- Pagespeed Error in Nginx
- Rewrite old post images to https
- Varnish + Nginx for WordPress is Good?
- Must I install a plugin for Nginx object caching? [closed]
- Access denied unless I add trailing /
- Pages, aside from admin-side and the home page, read “500 Internal Server Error – nginx/1.1.19”.
- Nginx how to redirect index.php
- In Nginx, how can I rewrite all http requests to https while maintaining sub-domain?
- Why do I need Nginx and something like Gunicorn?
- Nginx reverse proxy + URL rewrite
- How can I see which flags Nginx was compiled with?
- How to force or redirect to SSL in nginx?
- How do I add Access-Control-Allow-Origin in NGINX?
- nginx HTTPS serving with same config as HTTP
- How to reply with 200 from Nginx, without serving a file?
- Nginx config reload without downtime
- How do you restart php-fpm?
- Nginx enable site command
- How to remove the path with an nginx proxy_pass
- How to output variable in nginx log for debugging
- Make nginx to pass hostname of the upstream when reverseproxying
- connect() failed (111: Connection refused) while connecting to upstream
- Can I hide all server / os info?
- Nginx 1 FastCGI sent in stderr: “Primary script unknown”
- Nginx: How do I forward an HTTP request to another port?
- Setting expires headers for static content served from nginx
- How to restart nginx?
- How to disable timeout for nginx?
- What does this nginx error “rewrite or internal redirection cycle” mean?
- How does try_files work?
- nginx – client request body is buffered to a temporary file
- Do you need separate IPv4 and IPv6 listen directives in nginx?
- an upstream response is buffered to a temporary file
- Disable caching when serving static files with Nginx (for development)
- How to make a modification take affect without restarting nginx?
- How to use nested Nginx location blocks (prefixes vs. regex directives)?
- Nginx – root versus alias, for serving single files?
- Why do I need nginx when I have uWSGI
- What’s the difference between the “mainline” and “stable” branches of nginx?
- Loading WordPress Site Inside iframe won’t allow users to login
- Nginx upstream prematurely closed connection while reading response header from upstream, for large requests
- nginx progy pass doesn’t work in WordPress admin
- nginx or cherokee ( +php-fpm ) for WordPress backend?
- WordPress Multisite with multiple domains using Nginx
- NGinx + WordPress Subdomain Multi with core in Subdirectory
- how do I configure nginx for wordpress multisite, it occurs ERR_TOO_MANY_REDIRECTS
- HTTP_HOST changing in functions.php
- Nginx WordPress and another Web app URL structure
- Ubuntu 12.04, Nginx and MySQL issue with WordPress Database
- Possible to reverse proxy WP multisite to a separate server with NGINX?
- How to install WordPress on sub directory in ubuntu 16.4 in same vhost with AngularJS
- I have cloudflare flexible enabled, How to redirect to https for Nginx server
- Nginx Multisite redirects (incorrectly) on Chrome IE and Mobile, but works (correctly) on Firefox
- wordpress multisite is broken in nginx but working in apache