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 General Discussion
  • Search

weird problem,,redirecting to www and https

General questions about VestaCP
Post Reply
  • Print view
Advanced search
6 posts • Page 1 of 1
lokali
Posts: 14
Joined: Mon Dec 01, 2014 4:45 am

weird problem,,redirecting to www and https
  • Quote

Post by lokali » Thu Dec 31, 2015 3:50 am

i'm redirecting non www to www using htaccess

Code: Select all

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
it only redirects on homepage only.. when i type mydomain.com/suboage.html is not redirected to www.. how to redirect all subpage?

and the second redirecting to https using code

Code: Select all

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
it only redircts on homepage only too..when i type mydomain.com/suboage.html is not redirected to https.. how to redirect all subpage?
Top

mike08
Posts: 160
Joined: Sat Jun 20, 2015 7:12 am

Os: Debian 6x
Web: apache + nginx
Re: weird problem,,redirecting to www and https
  • Quote

Post by mike08 » Thu Dec 31, 2015 7:16 am

Hey lokali,

For the www redirect I have the following in .htaccess:

Code: Select all

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
And for https I have on: /home/admin/conf/web/nginx.conf the following:

Code: Select all

return      301     https://$server_name$request_uri;
So the settings for the nginx.conf virtual host look like this:

Code: Select all

server {
    listen      192.168.1.150:80;
    server_name localehost.com www.localehost.com;
    error_log  /var/log/apache2/domains/localehost.error.log error;
    return      301     https://$server_name$request_uri;
    ...
EDIT: Make sure to restart nginx after applying the config

Hope that helps.
Top

tjebbeke
Collaborator
Posts: 783
Joined: Mon May 11, 2015 8:43 am
Contact:
Contact tjebbeke
Website

Os: CentOS 6x
Web: apache + nginx
Re: weird problem,,redirecting to www and https
  • Quote

Post by tjebbeke » Thu Dec 31, 2015 8:55 am

I have this htaccess:

Code: Select all

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !localhost
    RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [L,R=301]

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]
</IfModule>
Top

lokali
Posts: 14
Joined: Mon Dec 01, 2014 4:45 am

Re: weird problem,,redirecting to www and https
  • Quote

Post by lokali » Thu Dec 31, 2015 10:52 pm

please help me ..all don't work

actually the rediredtion works on domain.com/ but not work on domain.com/index.html and work for domain.com/page/ but not work on domain.com/page.html

so all my html page not redirected

i dont know what rule i should insert :(

i have tried all rule on google and not work for static .html :(
Top

lokali
Posts: 14
Joined: Mon Dec 01, 2014 4:45 am

Re: weird problem,,redirecting to www and https
  • Quote

Post by lokali » Fri Jan 01, 2016 2:36 am

i can confirm that this is BUG of vestaCP

i have the following htaccess code, my htaccess redirect non www to www and http to https that WORK redirection .html on MY CPANEL HOSTING but not work on vestacp..i have installed fresh vestacp and get the same problem. so this is vestacp problem

Vestacp htacess redirection:
actually the rediredtion works on domain.com/ but not work on domain.com/index.html and work for domain.com/page/ but not work on domain.com/page.html

on cpanel hosting:
the same htaccess code work to redirect http to https and non www to www on all pages .html

i have tried htaccess on vestacp doc and it also not work to redirect .html

if you have htacess redirection,,just double check if it work on static .html page or not

so this is bug of vesta cp, because of this problem i'm considering to find another control panel

Code: Select all

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
Top

scetticus
Posts: 1
Joined: Sun Apr 05, 2020 4:13 pm

Os: CentOS 6x
Web: apache + nginx
Re: weird problem,,redirecting to www and https
  • Quote

Post by scetticus » Sun Apr 05, 2020 4:29 pm

If your problem is redirecting both yourdomain.com and www.yourdomain.com to https://www.yourdomain.com you have to follow the official guide at

https://vestacp.com/docs/#how-to-force-https

BUT THEN EDIT

/usr/local/vesta/data/templates/web/nginx/force-https.tpl

replacing all content with this:

Code: Select all

server {
    listen	%ip%:%proxy_port%;
    server_name %domain_idn% %alias_idn%;
    location / {
        rewrite ^(.*) https://%alias_idn%$1 permanent;
    }
include %home%/%user%/conf/web/*nginx.%alias_idn%.conf_letsencrypt;
}
You'll se that I changed only %domain_idn% with %alias_idn% in rewrite and include rules...

Remember to deselect, save, reselect and save again "force-https" as proxy template if you already installed and used it before... then restart both nginx and https.


Glad if this helps.
Top


Post Reply
  • Print view

6 posts • Page 1 of 1

Return to “General Discussion”



  • 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