I have a wordpress site accessed like http://example.com/
but my client wants to have it accessed like http://www.example.com/
I am finding this code as a solution
# 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
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ www.domain.com/$1 [L,R=301]
But I am getting an error of redirect loop
Could you please advice me what am i doing wrong?
You’re missing
http://
from yourwww
forcing rule. Also important is to have your www rule before other WP rules:Also don’t forget to change WP permalinks to have
www
in Site and Home URLsYou have an easy way to do this inside of wordpress:
Go to your wordpress dashboard and:
1) Select Settings
2) Select option General,
3) Add to your WordPress Address (URL) the www part
4) Add to your Site Address (URL) the www part
And done!