Joomla -redirect non-www URLs to www

In order to redirect all of the requests for yourdomain.com to http://www.yourdomain.com, you should set the appropriate rewrite rule. This can be done by adding the following lines at the beginning of the .htaccess file in your WWW folder:

RewriteCond %{HTTPS} !=on

RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]

RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]

From now on, when someone accesses http://yourdomain.com s/he will be redirected to http://www.yourdomain.com.

Using this method is safe because it should not create any redirection loops nor it should interfere with other rewrite rules.

In Joomla 1.5, we have to add above rule (code) in .htaccess file, before the joomla .htaccess rule.

so your .htaccess file look like this….

##  Can be commented out if causes errors, see notes above.

Options +FollowSymLinks
##  mod_rewrite in use
RewriteEngine On

#Custom rule(It must be before the joomla htaccess rule) for non www to www url:Start

RewriteCond %{HTTPS} !=on

RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]

RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]

#Custom rule for non www to www url:End
########## Begin – Rewrite rules to block out some common exploits

Advertisements

PHP Developer..

Tagged with: ,
Posted in .htaccess, Joomla 1.5
8 comments on “Joomla -redirect non-www URLs to www
  1. Perry Kimple says:

    Admiring the time and energy you put into your site and detailed information you present. It’s awesome to come across a blog every once in a while that isn’t the same out of date rehashed material. Great read! I’ve bookmarked your site and I’m including your RSS feeds to my Google account.

  2. Kerry says:

    Nicely put, With thanks.

  3. E Juice says:

    I don’t even know how I ended up here, but I thought this post was great. I do not know who you are but certainly you’re going to a famous blogger if you aren’t already 😉 Cheers!

  4. This article is in fact a nice one it helps new web visitors, who are wishing for blogging.

  5. I have read so many content about the blogger lovers except
    this paragraph is actually a pleasant article, keep it up.

  6. Good information. Lucky me I found your website by accident (stumbleupon).
    I’ve book-marked it for later!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: