131 次浏览

Automatically Jumping from the Domain without WWW to the Domain with WWW on BT Panel Settings

Last week, I applied for a free VPS host that needs to be manually renewed every 7 days. The speed of installing BT Panel is also very good. Then I installed the WordPress blog program, added a domain with WWW, and moved all the content of the previous blog to it. I added the domain and SSL on CloudFlare. After everything was ready, I found that the blog homepage could be normally opened when entering the domain with WWW in the browser address bar, but once I entered the domain without WWW, a 404 Not Found nginx page appeared. What is the reason then?

After using Google search, I found that there are many solutions to this problem, but they are all modified for the Nginx configuration file, such as: “我的Nginx 配置,域名不带www跳转到www,http强制跳转https,这些都有了” adding the following statement in the configuration file of nginx.conf:

server {

       listen 80;

       server_name www.your-domain.com;

       rewrite ^(.*)$  https://www.your-domain.com$1 permanent;

}

For example with a question post in the following forum, “求教:网站不带www,页面提示404“, someone answered as follows:

通过修改/usr/local/nginx/conf/vhost下面主机的conf,多添加一个不带www的域名就好了。写成这种样子:

server {

listen 80;

server_name nginx.org www.nginx.org;

}

However, I failed after similar operations on BT Panel. Inspired by an article “原因:您的请求在Web服务器中没有找到对应的站点的解决方法“, I modified the “Website-Settings-Configuration File” tab in the background of BT Panel by adding the domain without WWW according to the above format (as shown in the red box in the figure below) and thus solved the problem.

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注