Educational ICT Virtualisation Specialist

Twitter LinkedIn E-mail
Precedence Technologies Ltd
Technology House, 36a Union Lane
Cambridge, CB4 1QB, United Kingdom
T: +44 (0)8456 446 800 / +44 (0)1223 359900
E: enquiries@precedence.co.uk
Webserver-redirecthttps

Jump To: Support > KB > NetManager > Webserver > redirecthttps

Redirect all requests to HTTPS

Assuming you have enabled HTTPS on your webserver, you can easily set up the server to redirect all HTTP requests to HTTPS. To do this, create a .htaccess file in the root of your webspace (i.e. ~www/.htaccess or \\netmanager\webpages\.htaccess) containing the following:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

This will redirect to the same web-address as you entered which may not match your SSL certificate, e.g. http://netmanager/ would redirect to https://netmanager/. If you want to redirect to a specific hostname, use this instead of %{SERVER_NAME} in your .htaccess file, e.g.

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://intranet.mydomain.com/$1 [R,L]

If you want to only redirect to HTTPS when using a specific name (i.e. you don't want to redirect internal access, but do want to redirect external access), use something like this (N.B. this would still allow HTTP access if using http://external.ip.address.here/):

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} "^intranet\.mydomain\.com$" [NC]
RewriteRule ^/?(.*) https://%{HTTP_HOST}/$1 [R,L]

If you want to redirect to HTTPS when NOT using a specific name (i.e. you don't want to redirect internal access as http://netmanager/, but do want to redirect external access), use something like this:

RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} "!^netmanager$" [NC]
RewriteRule ^/?(.*) https://intranet.mydomain.com/$1 [R,L]
© Copyright Precedence Technologies 1999-2024
Page last modified on November 11, 2021, at 02:05 PM by sborrill