write two location blocks for nginx, that separately detect different types of url first…
- User
write two location blocks for nginx, that separately detect different types of url first url is like /print?site_path=url should redirect 301 to url second url is like /erere/rerere/print
i wrote first location /print { return 301 $arg_site_path; }
write second please
- Assistant
Certainly! Below are the two
locationblocks for nginx that match your requirements:- The first location block to handle URLs like
/print?site_path=urland perform a 301 redirection to theurl:
location /print { if ($arg_site_path) { return 301 $arg_site_path; } }- The second location block to handle URLs like
/erere/rerere/print:
location /erere/rerere/print { # Your handling logic here, e.g., return a specific response or proxy pass to another server. # Example: return 200 'This is the /erere/rerere/print endpoint.'; }Ensure you replace the comment in the second location block with the actual handling logic you want to implement for the URL.
- The first location block to handle URLs like