Custom Joomla website design and development.

Home Knowledge Base SEO (Search Engine Optimization) How to redirect non www requests to www requests with mod rewrite

How to redirect non www requests to www requests with mod rewrite

Rate this item
(0 votes)

Making sure that your website's domain name is being accessed from only one domain is important, though at first glance it may not be obvious exactly why. Google's PageRank system checks the back-links to your site on the web to try to get an idea of how important your site is overall. However, in this process it may consider example.com to be a different site from www.example.com. To prevent this from happening, you'll need to redirect your users from the non www domain, to the www one.

Simply create, a .htaccess file and add the following script to it. Just make sure to replace the example.com with your own domain name.

# To redirect all users to access the site WITH the www. prefix
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

Trevor Bice

Trevor Bice

Owner, Joomla Expert

...I'm a one man army

E-mail: This e-mail address is being protected from spambots. You need JavaScript enabled to view it