Make http:// goto http://www and get rid of trailing slashes

Category
.htaccess, drupal, modules, seo
Date Created
26th Mar 2010
Last Updated
17th Aug 2010

Make http:// goto http://www and get rid of trailing slashes

Question

How to make http:// goto http://www and get rid of trailing slashes

Answer

Update the .htaccess file as described below.

# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# adapt and uncomment the following:
RewriteCond %{HTTP_HOST} ^villa-la-herradura\.com$ [NC]
RewriteRule ^(.*)$ http://www.villa-la-herradura.com/$1 [L,R=301]

#get rid of trailing slashes
RewriteCond %{HTTP_HOST} ^(www.)?villa-la-herradura\.com$ [NC]
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]

Alternatively use the globalredirect module at http://drupal.org/project/globalredirect.

Related terms