4 ms·
Use return instead of rewrite. server { listen 80; server_name www.website.tld; return 301 http://website.tld$request_uri; }
by DonPellegrino 12y ago
Use return instead of rewrite.
server {
listen 80;
server_name www.website.tld;
return 301 http://website.tld$request_uri;
}
- scrollaway 12y agoPlease back up your claims with a reason - all you're giving us is a different way to do things here.
- peferron 12y agohttp://wiki.nginx.org/Pitfalls#Taxing_Rewrites http://wiki.nginx.org/Pitfalls#Taxing_Rewrites
- lewaldman 12y agoSEO. And it's just one reason.
- scrollaway 12y agoWhat does SEO have to do with this?
- lewaldman 12y agoIt counts as duplicated content. A 301 is a redirect. It sends to the client the instruction to reload the page in the given Address. A rewrite happens only on the server side. So for the client it's like two different sites with the same content, and this hurts your ranking. Now... Ok that I didn't explained that on the parent post (didn't thought it was needed), but is it enough reason to a downvote? :P edit: fixed grammar.
- scrollaway 12y agoRewrites in nginx are redirects.
- peferron 12y agoOnly a subset of rewrites are redirects. A common usecase for rewrites is to change the request URI to make it match another location block in your config, but without returning 301 or 302 or any other redirect code to the client.