Navigator


Archive

201139
201230
201312
20151
201633
201755
201865
201955
20234

Creation date:

Use site WITH WWW or WITHOUT WWW prefix

Many sites use url with and without www. Although it doesn't matter how to call the site in point of user view. But for analytics, website statistics and page ranking point of view it'll better to always use one version and redirect others to this version. Some sites redirect all userts to www version of site, others use the url without www and redirects all requests made against www to the version without www.

Redirect users to access the site WITHOUT WWW

To redirect all users to access the site WITHOUT WWW. prefix, (http://www.example.com/... will be redirected to http://example.com/...)write the following instruction in .htaccess

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

Redirect users to access the site WITH WWW

To redirect all users to access the site WITH WWW. prefix, (http://example.com/... will be redirected to http://www.example.com/...)write the following instruction in .htaccess

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

Author: Jafar N.Aliyev (Jsoft)

Read also

HTML tips

Here I listed some useful HTML tips

© Copyright

All articles in this site are written by Jafar N.Aliyev. Reproducing of any article must be followed by the author name and link to the site of origin(this site). This site also keeps the same rules relative to the articles of other authors.