Mobile app version of vmapp.org
Login or Join
Vandalay111

: Should 301 redirects from www to the naked domain include the path for SEO? I'm trying to sort out a redirect for my site from www to the "naked" domain. My redirect currently does this:

@Vandalay111

Posted in: #301Redirect #Nginx #Redirects #Seo #Url

I'm trying to sort out a redirect for my site from www to the "naked" domain.

My redirect currently does this:
example.com -> example.com example.com/test.html -> example.com


Is this the correct behaviour? My only concern is, is it correct for it to use a 301 redirect to bring it back to the front-page no matter where it has come from?

I would think this would be the expected behaviour would be this instead:
example.com -> example.com example.com/test.html -> example.com/test.html


I have implemented this redirect on the nginx web server.

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Vandalay111

3 Comments

Sorted by latest first Latest Oldest Best

 

@Shelley277

I'm always setup 301 redirect from example.com domain to example.com. This code helps you:

server
{
server_name example.com; return 301 $scheme://example.com$request_uri;
}

10% popularity Vote Up Vote Down


 

@Angela700

I would think this would be the expected behaviour would be this instead:
example.com -> example.com
example.com/test.html -> example.com/test.html


That's a good idea. Just map the last parts of the URL (particularly folder and file) from the old domain to the new domain. You can easily use mod-rewrite if you have apache. Just make an .htaccess file in the folder where the example.com document root is and add the following:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ example.com/ [R=301,L]


That way, everything will be nicely redirected over from the www version to the non-www version.


My only concern is, is it correct for it to use a 301 redirect to bring it back to the front-page no matter where it has come from?


The only time you should redirect a URL to the homepage is if that URL was the homepage in the past. For example, if your previous homepage was at the url www.example.com/homepage.html and the new homepage is just example.com, then you can use a 301 return code on www.example.com/homepage.html and redirect it to example.com.

Make sure you test everything as you go because you don't want to end up with too many redirects or you'll see a message in your browser something similar to "the document has moved here" and when you click on "here", the same message reappears.

10% popularity Vote Up Vote Down


 

@Ogunnowo487

The HTTP status code 301 is named "Moved Permanently":


The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs.


So the resource (i.e., your document) would stay the same, it just gets a new URI.

As your front page example.com/ is (usually) not the same resource as a page like www.example.com/test.html, it would not be correct to use the status code 301.

Or in other words: Yes, include the path.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme