How to Redirect Non WWW Website to WWW Version on

2019-09-15 05:00发布

I have hosted my Website on Digital Ocean & Installed Wordpress through Serverpilot. Current Home Page URL is www.xyz.com & xyz.com is also redirecting on it.

But When I open xyz.com/test-post its not rediecting on www.xyz.com/test-post. How can I Redirect it ?

1条回答
太酷不给撩
2楼-- · 2019-09-15 05:40

Set the www version of URL in WordPress Address (URL) and Site Address (URL) fields present under WordPress (backend) *Settings > General*

and then write this in your .htaccess file

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]

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

Hope this help you.

查看更多
登录 后发表回答