Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

Redirect WWW to non-WWW witn NginX & PHP-fpm

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
1 post • Page 1 of 1
desolator
Posts: 9
Joined: Wed Jan 11, 2017 8:42 am

Redirect WWW to non-WWW witn NginX & PHP-fpm
  • Quote

Post by desolator » Thu Oct 17, 2019 10:12 am

Hey everyone,

Am facing a problem with having accessible www and non-www in domain.
The problem is that the domain to be shown it should be the non-www but both are accessible. This is what i added to the template am using but it's not working.

Is there anyone who has the solution to this tweak?

Code: Select all

server {
         server_name "~^www\.(.*)$" ;
         return 301 $scheme://$1$request_uri ;
}

server {
    listen      %ip%:%web_ssl_port%;
    server_name %domain_idn% %alias_idn%;
    root        %sdocroot%;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/%domain%.log combined;
    access_log  /var/log/nginx/domains/%domain%.bytes bytes;
    error_log   /var/log/nginx/domains/%domain%.error.log error;

Thank you
Top


Post Reply
  • Print view
1 post • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password