Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove WWW prefix from your website

Tags:

url

web

How does Stack Overflow (and other web sites) remove the 'www' prefix when it's entered as part of a URL?

Is it a redirect, a rewrite or something else entirely?

Update: I'd specifically like to know in the context of IIS 6

like image 963
Rob Avatar asked Apr 28 '09 10:04

Rob


People also ask

Is www prefix needed?

Do You Need WWW in URLs? It's actually not necessary to use WWW in URLs. It exists for just one purpose—to identify the web address. This is not the case with other important URL signifiers, such as a File Transfer Protocol (FTP) server (ftp) or news server (news).

Can you leave out the www when typing a URL?

People tend to leave the www out when typing a website's address. It might not cause significant issues since visitors will reach the same page, but it's best to redirect site visitors to its www version. This is because your site's performance and SEO might be affected if you keep using non-www domains.

Why is there no www in front of my website?

In the case of Web sites that happen to work without the "www" prefix, it simply means that the administrator has decided that if there is no prefix, the IP address returned should be the IP address for the Web server. For more information, check out the links on the next page.

How do I remove www from WordPress?

WordPress. Removing the "www" from your WordPress site is easy. Simply open the WordPress Dashboard in your web browser and select General Settings in the left sidebar. Delete the "www" from the WordPress Address and Site Address URLs as shown below.


1 Answers

On Apache, it looks like this (inside an .htaccess file):

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
like image 124
Steven Richards Avatar answered Sep 24 '22 06:09

Steven Richards