Redirecting to appropriate subdomain

So I wanted my sites to redirect from http://domain.com to http://www.domain.com and found the following solution:

(in a .htaccess file)
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.com
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=permanent,L]

Also in order for this to work, you need to have at least the following in the ‘sites-enabled/000-default‘ file under your Apache configuration:
Options FollowSymLinks
AllowOverride All


Using 301 Redirection

If you don’t use a 301 redirect, and use a 302 redirect instead, many search engines will drop you from their listings. The 302 redirect is the typical <META HTTP-EQUIV=”Refresh” CONTENT=”0; URL=http://www.domain.com”> tag.

Now there is more than what I have listed here, but this is what I found useful:

(in a .htaccess file)
Redirect 301 / http://www.domain.com

Categories: Website

0 Comments

Leave a Reply

Avatar placeholder

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.