Ashish
Ashish

Reputation: 429

redirect my site from example.info to www.example.info using .htaccess

i have just completed making a site using wordpress. i can access my site using the site's url which is for example 'example.com'. now what i want is whenever someone enter example.com in their browser's address bar i want it to appear http://www.example.com. also on on any other post and pages as: http://www.example.com/page, http://www.example.com/post .i know this is done by writing some redirect thing on .htaccess file,but i just dont know what.currently by deafult my .haccess file contains this code:

# BEGIN WordPress

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    # END WordPress

Upvotes: 0

Views: 67

Answers (2)

Sachin G.
Sachin G.

Reputation: 522

Why is so complicated? It's So simple.

  1. Login to Wordpres
  2. Go To Settings >> General
  3. Change WordPress Address (URL) & Site Address (URL) - add www in your URL
  4. Save Changes....

It's Done

Upvotes: 0

anubhava
anubhava

Reputation: 785491

You can do it in 2 ways:

  1. Use WP settings
  2. Use .htaccess

For 2. modify your rules to this:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]

RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Upvotes: 2

Related Questions