Reputation: 429
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
Reputation: 522
Why is so complicated? It's So simple.
It's Done
Upvotes: 0
Reputation: 785491
You can do it in 2 ways:
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