Score:1

Apache http to https WITHOUT any adress?

ye flag

a normal http to https rewrite could look like this:

RewriteEngine On
# RewriteCond %{HTTP_HOST} !^example.com$
# RewriteRule /.* https://example.com/ [R]

but this code specifies the site to "example.com"

Is there anyway to make a "global" rewrite, so regardless if anybody opens example.com, broken.example.com or even example.Lom, (as long as the DNS is pointing to the server) so will it simply put a https on it?

for servers that have more than one domain name.

Would be great to be able to use the same code everywhere..

Score:0
it flag

You can use the following code in any virtual host to redirect http to https:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

You can set it globally by setting the code in your default virtualhost (/etc/apache2/sites-available/000-default.conf on debian) to redirect any http request on any domain to its https version:

<VirtualHost *:80>
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    ...
</VirtualHost>
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.