M3Server Technical Blog FAQ Mini Howto: redirect non www to www

Mini Howto: redirect non www to www



Sometimes its needed for site functionality for the www to appear in the URL for some scripts and to just make the site cleaner and more consistent. You can do so with htaccess !

The these lines to your root .htaccess file:


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

Make sure you save it as:
.htaccess

Also, TEST TEST TEST! Make sure you didn’t get a typo in your entry.

The above URL:
http;//m3xs.com/ will auto switch to https://www.m3xs.com/

Note: Mod_rewrite will be executed before the 301 redirect statement. If you have any mod_rewrite rules this entry will need to be put above those.

– M3Server.com – world.class.hosting

Leave a Reply