Liferay 7.3 — Force HTTPS Redirection With Apache

Keywords: Liferay - AWS - Technical issue - Secure Connections (SSL/HTTPS)
Description:
I have HTTPS and my SSL Certificate working fine, but cannot get Apache to redirect incoming URLs to httpS.

What I have done so far is the following …

Using this information from Bitnami: https://docs.bitnami.com/aws/apps/wordpress/administration/force-https-apache/

I added the following to the following file: /opt/bitnami/apache2/conf/bitnami/bitnami.conf

DocumentRoot "/opt/bitnami/apache2/htdocs" RewriteEngine On RewriteCond %{HTTPS} !=on RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1) RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L] ...

I then RESTARTED Apache — Still not redirecting.

I then Stopped my AWS instance and started it again — Still isn’t redirecting the URL to httpS

Any ideas would be appreciated.

Thanks, Nick.

The section of my file looks like this …

DocumentRoot "/opt/bitnami/apache2/htdocs"

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

Options Indexes FollowSymLinks
AllowOverride All
<IfVersion < 2.3 >
  Order allow,deny
  Allow from all
</IfVersion>
<IfVersion >= 2.3 >
  Require all granted
</IfVersion>

Error Documents

ErrorDocument 503 /503.html

Bitnami applications installed with a prefix URL (default)

Include “/opt/bitnami/apache2/conf/bitnami/bitnami-apps-prefix.conf”

Hello @n_burton,

We have a Support Tool that will gather relevant information for us to analyze your configuration and logs. Could you please execute it on the machine where the stack is running by following the steps described in the guide below?

Please note that you need to paste the code ID that is shown at the end.

Regards

Thanks David,

I have just Private Messaged you.

BW

Nick

David, you now have access to the .ZIP file.

BW

Nick

Hello @n_burton,

Sorry for the delay. Could you move your redirection code out of the Directory block?

from

<VirtualHost _default_:80>
  DocumentRoot "/opt/bitnami/apache2/htdocs"
  <Directory "/opt/bitnami/apache2/htdocs">

  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
  RewriteRule ^/(.*) https://www.XXXXX.co.uk/$1 [R,L]

    Options Indexes FollowSymLinks

to

<VirtualHost _default_:80>
  DocumentRoot "/opt/bitnami/apache2/htdocs"

  RewriteEngine On
  RewriteCond %{HTTPS} !=on
  RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
  RewriteRule ^/(.*) https://www.XXXXXX.co.uk/$1 [R,L]

  <Directory "/opt/bitnami/apache2/htdocs">
    Options Indexes FollowSymLinks

and restart apache

Regards

1 Like

Thanks,

That worked perfectly. Human error (aren’t they all?).

Thanks again.

Nick

1 Like

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