Why redirect www to non www




















When a URL is written in two different ways www and non-www it means the same website appears online under two different domains. This then leads to internal duplicate content , making it harder for Googlebot to find the page most relevant for a particular search term and to index it correctly.

In addition, Google interprets links that actually refer to the same website but once with and once without www as links to separate pages, which distributes the link power between the www and the non-www domain.

Thus, both domains rank worse than would be the case if the link power were bundled on one variant of the website. Apart from its relevance for search engine optimization, the choice of a preferred domain www or non-www is also part of a clean technical setup of a website and therefore mandatory for every webmaster.

If a website is accessible with both a www and a non-www link, a redirect to the preferred domain should always be set up. It all boils down to your personal preference. Oftentimes, most webmasters decide between nonwww to www or to redirect www to nonwww based on aesthetics. Non-www URLs are shorter and oftentimes cooler to look at , compared to their www counterpart.

What matters is specifying which format you prefer, and then redirect visitors to your chosen URL format. To edit your htaccess file, you need the means to access it.

The easiest way to access and edit the. Simply put the following lines of code into your main, root. In both cases, just change out domain.

Start selling products, sending newsletters, publishing ads, and more through your own WordPress website using our premium WordPress plugins. Toggle navigation. Redirecting to www or non-www « Hosting. View the code on Gist. Like this: Like Loading Oldskool Luke Luke 21 1 1 bronze badge. You need to place non-www redirection rules before those you have quoted.

Rajith Ramachandran Rajith Ramachandran 1, 1 1 gold badge 9 9 silver badges 9 9 bronze badges. RewriteEngine on if host value starts with "www. Amit Verma Amit Verma Universal Omega Universal Omega 5 5 silver badges 26 26 bronze badges. The only way I got it to work Apache can listen another port, e. This is updated to work on Apache 2. William Entriken William Entriken The earlier answer did not need "updating to work on Apache 2.

The "warning" you are quoting AH relates to a different directive eg. The NC flag makes little difference in the above, however, the reason the NC flag should be used here is to catch the small fraction of bot traffic that incorrectly sends an uppercase hostname. Alternative approach if. That website now says "This service will be closed soon. I am not sure why u want to remove www. But reverse version would be: non-www.

Whether the www subdomain should be included or not is really a matter of personal preference and can depend on the domain name and target audience. The generic code posted above for redirecting www to none-www also handles test environments OK, since the redirect only occurs when the "www.

This question does the opposite of what the user is asking, which is only polluting the post. Jeaf Gilbert Jeaf Gilbert Please elaborate your code so that the OP understands how this answers the question. Chirag Parekh Chirag Parekh 6 6 silver badges 13 13 bronze badges.

The question is asking for a "generic" solution that does not include the domain name. Your solution also does the complete opposite of what is asked for in the question non-www to www, rather than www to non-www without explanation. The Overflow Blog. Does ES6 make JavaScript frameworks obsolete? Podcast Do polyglots have an edge when it comes to mastering programming Featured on Meta.



0コメント

  • 1000 / 1000