How to redirect www on the https


#1

how to redirect www on the https, when i writing www.lukjack.eu or lukjack.eu in browser not redirect website https://lukjack.eu, why please help


#2

Generally a bit more information about your system / setup would be very useful to be able to give you a suitable answer ( what is your operating system, are you using apache, nginx or something else as a webserver … ?) . However your web page seems to be an apache2 default page on Ubuntu, so I’ll answer on that basis :slight_smile:

The easiest is to add something like

   RewriteEngine On
   RewriteCond %{HTTPS} off
   RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge/
   RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

into either the http part of your apache config file for the domain, or you can place it in your .htaccess file for the domain.


#3

my operating system: ubuntu 16.04, server www apache 2.4.18, but where to enter?


#4

@lukjack92, it will be a configuration file inside /etc/apache2/sites-available that relates to your particular domain. That is “your apache config file for the domain” that @serverco mentions.


#5

I did it, in file 000-default.conf adding “Redirect / permanent https://lukjack.eu” and it is work :slight_smile:
Close topic. Thank you guys @serverco and @schoen


#6

@lukjack92, I’m not positive that file is the right one if you plan to host other domains on the same server in the future. However if you only plan to host this one single domain there, it might not be a problem. Please keep that in mind in case you do add other domains (the redirect will need to be in an appropriate file for each domain, so that not all of the other domains have this redirect applied!).

I’m glad it’s working for you!


#7

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.