redirect domain.com to www.domain.com Drucken

  • 30

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 and even improve search engine optimization. You can do so with htaccess!

WARNING!  MAKE A BACKUP OF YOUR FILE FIRST AND FOREMOST FOR QUICK REVERSAL.

Then these lines to the top of your root .htaccess file:
# BEGIN CODE #
RewriteEngine On
Options +FollowSymLinks
RewriteCond %{HTTP_HOST} ^m3xs\.com$ [NC]
RewriteRule ^(.*)$ http://www.m3xs.com/$1 [R=301,L]
# END CODE #

If you don't have a current .htaccess file, just create a plain text document in notepad or textedit and ake sure you save it as:
.htaccess
Upload this .htaccess to your site's main directory where your main index file is.

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

In this example, the above URL:
http;//m3xs.com/ will auto switch to http://www.m3xs.com/
Naturally, replace m3xs.com with your actual domain name as this is an EXAMPLE only.

Tip!  Make sure you click a few links inside your site.  If you have WordPress or other PHP scripts, make sure they are configured to MATCH your htaccess settings, otherwise, your site could end up in a redirect loop.


War diese Antwort hilfreich?

« Zurück