Redirect wordpress site to www from non www on wordpress server

91 views Asked by At

I am working on a Wordpress project which is deployed on wordpress.com hosting. Simply I want to redirect the website from (with SSL)non-www to (with SSL) www.

I have searched over web and there are plenty of plugins who does the job, but there is a problem with wordpress hosting, it redirects back from www to non-www and resuslts error "too many redirects". I tried to change settings from admin panel settings> General > site url. But its disabled there, I cannot change it. This option is enabled to change on other hosting servers but not on wordpress.com hosting.

I tried it to do that through htaccess but still not working.

if information is not enough I can provide more info.

Kindly help me out with this problem.

Thanks in advance!

1

There are 1 answers

0
Ali Qorbani On

This is simple with .htaccess file.

<IfModule mod_rewrite.c>
    RewriteEngine On    
    RewriteCond %{HTTPS}=off[OR]
    RewriteCond %{HTTP_HOST}!^example\.com$
    RewriteRule ^(.*)$"https://example.com/$1" [R=301,L]
    # remaining htaccess mod_rewrite CODE for WordPress
</IfModule>