As for the other issue... caching perhaps?
Thats what i thought at first too... But its every device on the network cannot access that site, but when i get off the network, works fine. Ill make a new topic for it.
Link to the new topic.
Change this:
to just:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1
That's already been replaced by certbot. I'm not sure with what though.
@griffin, I just don't get why all examples always check the name before redirecting.
If the block has the server_name, then it's a redundant name check.
If the block has no server_name ("default"), no harm is done by sending those requests to HTTPS.
And in the worst possible case, when an alias is added above that section but not included in that section, that alias doesn't get redirected and might actually reach a document root that it wasn't intended to reach. As an example: Over time, the document root may get changed in HTTPS (only).
[Apache will always try to serve something!]
I totally get it. I think it's just generic, "safe" coding on the part of certbot.
If you want to be really efficient, according to Apache this is the very best way:
<VirtualHost *:80>
ServerName newkiddintown.com
ServerAdmin webmaster@localhost
Redirect permanent "/" "https://newkiddintown.com/"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName www.newkiddintown.com
ServerAdmin webmaster@localhost
Redirect permanent "/" "https://www.newkiddintown.com/"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Take note that there are no rewrites and no DocumentRoots.
Why have two blocks?
They can be combined easily with one alias line.
They are separate server names redirected to separate addresses. This is necessary for HSTS.
You're saying they serve different content?
If not, then they are one and the same.
It can still be combined - if you use an Apache variable instead of hardcoding the name.
[HTTP_HOST]
Howcome?
They serve NO content. They have NO DocumentRoots. They only redirect.
But they have no TLS also.
So if I redirect my site to yours (badly)...
Then I can brake your sites' HSTS?
Because HSTS to my knowledge requires...
http://domain.com -> https://domain.com
http://www.domain.com -> https://www.domain.com
Only the protocol is supposed to change, not the host name.
Correct. Those VirtualHosts are only there to catch incoming http connections on port 80 and redirect them to https.
I don't understand how this relates.
I seem to remember JuergenAuer mentioning a while back that...
http://domain.com -> https://www.domain.com
was inappropriate for HSTS and that it should be...
http://domain.com -> https://domain.com -> https://www.domain.com
First redirect to https then to www or apex.
http > http > https is bad
http > https is good
I don't know that that it really matters so much if they aren't to/from the exact same FQDN.
I only mentioned http -> httpS -> httpS