Welcome Guest. Please Login or Register  


You are here: Index > Webuzo > General Support > Topic : Force www. on primary domain



Normal Mode | Print  

 Force www. on primary domain (3 Replies, Read 14394 times)
erile
Group: Member
Post Group: Working Newbie
Posts: 64
Status:
Hello,

I would like to force www.domain.com for domain.com. So, I added an extra conf from Webuzo about domain.com with this content:
Code
if ($server_name = 'domain.com'){
  return 301 https://www.$server_name$request_uri;}

But it enters in infinite loop raising an ERR_TOO_MANY_REDIRECTS error.

First, I thgough it was due to the fact I also added code to force SSL whatever the domain in /usr/local/apps/nginx/etc/conf.d/common, like this:
Code
if ($scheme = 'http'){
      return 301 https://$server_name$request_uri;}

Then, searching for a solution I saw that the the recommended way from Nginx is to provide two separated server blocks for domain.com and www.domain.com, then only add the redirection in the domain.com one. Something like this:
Code
server {
  server_name www.domain.com;
  ...
}
server {
  server_name domain.com;
  return 301 https://www.$server_name$request_uri;
  ...
}

And knowing port 80 and 443 are already two blocks, it could gives four server blocks.

How to achieve this, knowing Webuzo keeps control on webuzoVH.conf containing the server blocks? Or is there another way to do it with Webuzo?

TIA

-----------------------
OpenVZ VPS, CentOS 7, Webuzo Premium / Desktop and full-stack dev w/ C, C++, Python, Perl, javascript...
IP: --   


Threads
 erile   Force www. on primary domain (3 Replies, Read 14394 times)
    |--  erile   Unless mistake (I'll...   on August 18, 2019, 10:34 pm
    |--  Dhanya   Hi, In order...   on August 19, 2019, 1:01 pm
    |--  erile   I know this,...   on August 20, 2019, 11:56 am

« Previous    Next »

Normal Mode | Print  



Users viewing this topic
1 guests, 0 users.


All times are GMT. The time now is April 19, 2024, 10:36 am.

  Powered By AEF 1.0.8 © 2007-2008 Electron Inc.Queries: 11  |  Page Created In:0.032