Replies: 3 comments 9 replies
-
I've written a blog on how to enable security: With Apache, you can use a .htaccess file to redirect HTTP to HTTPS. .htaccess <IfModule mod_rewrite.c>
SetEnv HTTP_MOD_REWRITE On
RewriteEngine On
RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R=301,L]
# This rule will redirect users from their original location to the same location but using HTTPS.
# i.e. http://www.example.com/foo/ to https://www.example.com/foo/
# The leading slash is made optional so that this will work either in
# httpd.conf or .htaccess context
</IfModule> |
Beta Was this translation helpful? Give feedback.
-
I discovered an easier way than my previous explanation: First complete the full Laragon install, open the app and do the basic configuration (enabling ssl, setting the name for the virtual hosts, then clicking apache in the menu and setting the ssl cert for windows....) THEN Edit "C:\laragon\bin\apache\httpd-2.4.54-win64-VS16\conf\httpd.conf" and look for: <Directory "C:/laragon/www">
Create a file in the www root called .htaccess for example: Add the content below and save RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]I've attached a .txt file with the full details! |
Beta Was this translation helpful? Give feedback.
-
@isitmeor Here's something that's working for me. Thanks to @sohosynergy suggestion which didn't work for me, I came up with something simpler. This would of driven me insane if I couldn't have found a solution. I am just forcing a simple rewrite on the port 80 to 443, the thing is it does this prior to wordpress install, which means it installs as https. It also writes the vhost conf with this forced change so it persists within Laragon, including apache version change. This could affect other stuff, but if you're wanting simple wordpress installs with https every time then this will do it. update: C:\laragon\usr\tpl\VirtualHost.tpl (make a backup first) define ROOT "<<PROJECT_DIR>>"
define SITE "<<HOSTNAME>>"
<VirtualHost *:<<PORT>>>
ServerName ${SITE}
ServerAlias *.${SITE}
# Redirect all HTTP traffic to HTTPS
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</VirtualHost>
<VirtualHost *:<<SSL_PORT>>>
DocumentRoot "${ROOT}"
ServerName ${SITE}
ServerAlias *.${SITE}
<Directory "${ROOT}">
AllowOverride All
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile <<SSL_DIR>>/<<HOSTNAME>>.crt
SSLCertificateKeyFile <<SSL_DIR>>/<<HOSTNAME>>.key
</VirtualHost> Opening links going forwards works, but it doesn't seem to affect sites created before this edit. You'd have to manually fix vhost confs for them. This really needs to be handled better by Laragon, but that's up to the author @leokhoa to fix. (He's a super star, this project is awesome) |
Beta Was this translation helpful? Give feedback.
-
How can I force http to https on installations of new (wordpress) sites
Having set SSL enabled it would be nice when the system uses https during the installation
Beta Was this translation helpful? Give feedback.
All reactions