all...
I am trying to do something in nginx to redirect all calls for files in
/images/
to become in:
/assets/images/
can someone help me with the rewrite rule? giving a 301 moved permanently status?
Temporary and Permanent Nginx Redirect Explained To map this change, the redirects response code 301 is used for designating the permanent movement of a page. These kinds of redirects are helpful when the user wants to change the domain name and no longer wants a browser to access it.
It is exactly the $uri/ part that makes nginx assuming an URI can be a directory name and looking for an index file presence inside it.
The try_files directive exists for an amazing reason: It tries files in a specific order. NGINX can first try to serve the static content, and if it can't, it moves on. This means PHP doesn't get involved at all.
Here's the preferred way to do this with newer versions of Nginx:
location ~ ^/images/(.*) { return 301 /assets/images/$1; }
See https://www.nginx.com/blog/creating-nginx-rewrite-rules/ for more info.
Add below configuration into your nginx.conf
rewrite ^/(images.*) /assets/$1 permanent;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With