I use NGINX in my dedicated server.
I've a question about the return and rewrite 301.
Rewrite 301:
rewrite ^ http://xxx.xxxxx.net/xx-xxx/$request_uri? permanent;
Return 301:
location ~ redirect-this/?$ {
return 301 http://xxx.xxxxx.net/xx-xxx/redirect-this$1;
}
All redirects work correctly. But..
Which is the most effective method to make a 301 redirect?
I've more than 200 url to redirect. So, what you recommend?
301 Permanent Redirection Permanent redirection will inform the browser that the website is no longer available with the old URL and this information should be updated and this point to the new URL we published.
NGINX rewrite rules are used to change entire or a part of the URL requested by a client. The main motive for changing an URL is to inform the clients that the resources they are looking for have changed its location apart from controlling the flow of executing pages in NGINX.
According to the NGINX documentation, use return if you can. It is simpler and faster because NGINX stops processing the request (and doesn't have to process a regex).
Simply put, a redirect is a client-side request to have the web browser go to another URL. This means that the URL that you see in the browser will update to the new URL. A rewrite is a server-side rewrite of the URL before it's fully processed by IIS.
As stated in the nginx pitfalls you should use server blocks and return
statements as they're way faster than evaluating RegEx via location
blocks.
Since you're forcing the rewrite rule to send a 301 there's no difference when it comes to SEO, btw..
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