Redirect xyz.com to www.xyz.com

Many times we meet with a situation where we need to redirect root domains to www. With apache htaccess file you can put the following rule in .htaccess file of webroot directory of your domain

  • cd /path/to/webroot
  • vim .htaccess
  • Add the following code

# Enable Rewrite Engine

RewriteEngine on
RewriteCond %{HTTP_HOST} ^mylinuxtips\.info
RewriteRule ^(.*)$ https://mylinuxtips.info/$1 [R=permanent,L]

NOTE: You must have your mod rewrite enabled to achieve this redirection.

Enjoy!!!

Leave a Reply

Your email address will not be published. Required fields are marked *