How to Redirect Non WWW Website to WWW Version on Unmanager Server?

你。 提交于 2019-12-25 07:49:23

问题


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:


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

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.



来源:https://stackoverflow.com/questions/41197632/how-to-redirect-non-www-website-to-www-version-on-unmanager-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!