We are happy to announce that Vesta is back under active development as of 25 February 2024. We are working on v1 candidate and expect to engage more with the community over the coming months. We are committed to open source, and we encourage contributors to help us build the future of Vesta.
cannot make redirect from www to non-www
-
- Posts: 258
- Joined: Fri Jan 10, 2014 7:34 pm
cannot make redirect from www to non-www
Putting the code in this place: /usr/local/vesta/nginx/conf/nginx.conf
Then: service nginx restart
Visitng mysite.com - ok, but when i visit www.mysite.com it doesn't redirects me to mysite.com
What's wrong?
Code: Select all
http {
server {
server_name “~^www\.(.*)$” ;
return 301 $scheme://$1$request_uri;
}
}
Visitng mysite.com - ok, but when i visit www.mysite.com it doesn't redirects me to mysite.com
What's wrong?
Re: cannot make redirect from www to non-www
Are you using nginx to serve the page completely or as a reverse proxy to Apache?
-
- Posts: 258
- Joined: Fri Jan 10, 2014 7:34 pm
Re: cannot make redirect from www to non-www
Using it as default, probably as reverse proxy but im not sure first time using nginx. How to check it? :)jarland wrote:Are you using nginx to serve the page completely or as a reverse proxy to Apache?
Re: cannot make redirect from www to non-www
In your public_html folder make a .htaccess file and include these contents. Replace domain.com with your domain, make sure to leave the \ in there.
Code: Select all
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?domain\.com)$ [NC]
RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]
-
- Posts: 258
- Joined: Fri Jan 10, 2014 7:34 pm
Re: cannot make redirect from www to non-www
Still not working :( When i was creating a domain name it had Alias option and it was http://www.domain.com i have tried to delete it but no success. And when nginx is a reverse proxy with apace - htaccess files should work?jarland wrote:In your public_html folder make a .htaccess file and include these contents. Replace domain.com with your domain, make sure to leave the \ in there.
Code: Select all
RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?domain\.com)$ [NC] RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]
UPDATE, sorry it works now misspelled one sign.
Last edited by heihachi88 on Fri Jan 17, 2014 8:09 pm, edited 1 time in total.
Re: cannot make redirect from www to non-www
Yeah I use htaccess pretty heavily. I suppose you could always do it the easy way, the way I do it. I just make www a CNAME pointing to my domain. Like this:
www 14400 IN CNAME jarland.me
www 14400 IN CNAME jarland.me
-
- Posts: 258
- Joined: Fri Jan 10, 2014 7:34 pm
Re: cannot make redirect from www to non-www
Thanks will try that :) When nginx is a reverse proxy - htaccess works only for redirects? Can i set max_upload_size for each site individually? Or it's impossible because of nginx?jarland wrote:Yeah I use htaccess pretty heavily. I suppose you could always do it the easy way, the way I do it. I just make www a CNAME pointing to my domain. Like this:
www 14400 IN CNAME jarland.me
Re: cannot make redirect from www to non-www
With nginx as reverse proxy, as is the default setting, you can make full use of Apache .htaccess files so long as you're using code that corresponds to an available Apache module. The most effective configuration, in my opinion, is to have Apache set to hosting and nginx set to caching. All Apache code is interpreted by Apache, nginx is just caching some stuff to speed up the process, but it passes everything to Apache as necessary.heihachi88 wrote:Thanks will try that :) When nginx is a reverse proxy - htaccess works only for redirects? Can i set max_upload_size for each site individually? Or it's impossible because of nginx?jarland wrote:Yeah I use htaccess pretty heavily. I suppose you could always do it the easy way, the way I do it. I just make www a CNAME pointing to my domain. Like this:
www 14400 IN CNAME jarland.me
-
- Posts: 258
- Joined: Fri Jan 10, 2014 7:34 pm
Re: cannot make redirect from www to non-www
So you advice to set apache to hosting and nginx to caching?jarland wrote:With nginx as reverse proxy, as is the default setting, you can make full use of Apache .htaccess files so long as you're using code that corresponds to an available Apache module. The most effective configuration, in my opinion, is to have Apache set to hosting and nginx set to caching. All Apache code is interpreted by Apache, nginx is just caching some stuff to speed up the process, but it passes everything to Apache as necessary.heihachi88 wrote:Thanks will try that :) When nginx is a reverse proxy - htaccess works only for redirects? Can i set max_upload_size for each site individually? Or it's impossible because of nginx?jarland wrote:Yeah I use htaccess pretty heavily. I suppose you could always do it the easy way, the way I do it. I just make www a CNAME pointing to my domain. Like this:
www 14400 IN CNAME jarland.me
Nice thing, i didn't know that i can make a full use of htaccess with nginx as reverse proxy :)
Also can you enlighten me about PECL uploadprogress with such combination? Is there any possibilities to see an upload progress?
Re: cannot make redirect from www to non-www
You can try running "pecl install uploadprogress" but you might need the PHP development package. On CentOS, "yum install php-devel" or on Debian/Ubuntu "apt-get install php-dev" (or maybe php5-dev). No luck for me installing php-devel on CentOS 6.5 at the moment after a stock Vesta install. Dependency issues.heihachi88 wrote: Also can you enlighten me about PECL uploadprogress with such combination? Is there any possibilities to see an upload progress?