Apache2 is one of the most widely used HTTP server has a lot of features and can be customized in many ways.
In fact, to this web server, there are basically two ways you can do this, using .htaccess directives or using a file httpd.conf. .
Some people prefer to use. htaccess files, since they reside in the website and can be modified by the site owner, which is not the case for the daemon configuration file:
ServerName debian-tutorials.comRedirectMatch permanent ^/(.*) http://www.debian-tutorials.com/$1DocumentRoot/path/to/your/site/files/ServerName www.debian-tutorials.com
ServerName www.debian-tutorials.comRedirectMatch permanent ^/(.*) http:///$1debian-tutorials.comDocumentRoot/path/to/your/site/files/ServerNamedebian-tutorials.com
RewriteEngine OnRewriteCond %{HTTP_HOST} ^\.com$ [NC]debian-tutorialsRewriteRule ^(.*)$ http://www./$1 [R=301,L]debian-tutorials.com
Permanent redirect from WWW to NON WWW using htaccess.:
RewriteEngine OnRewriteCond %{HTTP_HOST} ^www\.\.com$ [NC]debian-tutorialsRewriteRule ^(.*)$ http://debian-tutorials.com/$1 [R=301,L]















Hmm.. using RedirectMatch for such simple redirects seems a little overkill. You could do the same with Redirect to avoid the regular expression matching to happen (since anyway you want to simple redirect to the same thing under www):
Redirect permanent / http://www.debian-tutorials.com/