nativeInstallercoppermine

Redirect custom domains to the Apache server

Before running the commands shown on this page, you should load the Bitnami stack environment by executing the installdir/use_APPNAME script (Linux and MacOS) or by clicking the shortcut in the Start Menu under “Start -> Bitnami APPNAME Stack -> Application console” (Windows). On OS X VMs, the installation directory is /opt/bitnami and OS X VM users can click the “Open Terminal” button to run commands. Learn more about the Bitnami stack environment and about OS X VMs.
  • Add a ServerAlias in the installdir/apps/APPNAME/conf/httpd-vhosts.conf file for your application. This option is designed to specify alternate names for a host and is used when matching requests. Here’s an example:

    <VirtualHost *:80>
    ServerName app.example.com
    ServerAlias www.app.example.com app.example.org www.app.example.uk.org
    ...
    
    <VirtualHost *:443>
    ServerName app.example.com
    ServerAlias www.app.example.com app.example.org www.app.example.uk.org
    ...
    

    You will also need to create new certificates for each virtual host running on port 443 or use existing certificates, such as the default certificates shipped with the stack. You can do this by updating the SSLCertificateFile and SSLCertificateKeyFile directives for the virtual host to reflect the correct path for each virtual host’s certificates, as shown in the sample lines below, or by creating symlinks to the default certificates.

    ...
    SSLCertificateFile "/opt/bitnami/apps/APPNAME/conf/certs/app.example.com.crt"
    SSLCertificateKeyFile "/opt/bitnami/apps/APPNAME/conf/certs/app.example.com.key"
    ...        
    
  • Check that the installdir/apache2/conf/bitnami/bitnami-apps-vhosts.conf file includes the httpd-vhosts.conf file for your application. It should include a line like the one below.

    Include "installdir/apps/APPNAME/conf/httpd-vhosts.conf"
    

    If it does not, add the line above to the installdir/apache2/conf/bitnami/bitnami-apps-vhosts.conf file, replacing the APPNAME placeholder with the correct directory name for your application.

  • After modifying the Apache configuration files, restart Apache to apply the changes.

Redirect www.myapp.example.com to myapp.example.com

This redirection is an SEO “best practice”.

  • Add the following in the installdir/apps/APPNAME/conf/httpd-vhosts.conf file for your application.

    <VirtualHost *:80>
    ServerName app.example.com
    ServerAlias www.app.example.com
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ http://%1$1 [R=permanent,L]
    ...
    
    <VirtualHost *:443>
    ServerName app.example.com
    ServerAlias www.app.example.com
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1$1 [R=permanent,L]
    ...
    

    You will also need to create new certificates for each virtual host running on port 443 or use existing certificates, such as the default certificates shipped with the stack. You can do this by updating the SSLCertificateFile and SSLCertificateKeyFile directives for the virtual host to reflect the correct path for each virtual host’s certificates, as shown in the sample lines below, or by creating symlinks to the default certificates.

    ...
    SSLCertificateFile "/opt/bitnami/apps/APPNAME/conf/certs/app.example.com.crt"
    SSLCertificateKeyFile "/opt/bitnami/apps/APPNAME/conf/certs/app.example.com.key"
    ...        
    
  • Check that the installdir/apache2/conf/bitnami/bitnami-apps-vhosts.conf file includes the httpd-vhosts.conf file for your application. It should include a line like the one below.

    Include "installdir/apps/APPNAME/conf/httpd-vhosts.conf"
    

    If it does not, add the line above to the installdir/apache2/conf/bitnami/bitnami-apps-vhosts.conf file, replacing the APPNAME placeholder with the correct directory name for your application.

  • After modifying the Apache configuration files, restart Apache to apply the changes.

Redirect myapp.example.com to www.myapp.example.com

  • Add the following in the installdir/apps/APPNAME/conf/httpd-vhosts.conf file for your application. Or, to apply this redirection by default for all applications installed, add it to the default VirtualHost in the installdir/apache2/conf/bitnami.conf file.

    <VirtualHost *:80>
      ServerName app.example.com
      ServerAlias www.app.example.com
      RewriteEngine On
      RewriteCond %{HTTP_HOST} !^www\. [NC]
      RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
     ...
    
    <VirtualHost *:443>
      ServerName app.example.com
      ServerAlias www.app.example.com
      RewriteEngine On
      RewriteCond %{HTTP_HOST} !^www\. [NC]
      RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
     ...
    

    You will also need to create new certificates for each virtual host running on port 443 or use existing certificates, such as the default certificates shipped with the stack. You can do this by updating the SSLCertificateFile and SSLCertificateKeyFile directives for the virtual host to reflect the correct path for each virtual host’s certificates, as shown in the sample lines below, or by creating symlinks to the default certificates.

    ...
    SSLCertificateFile "/opt/bitnami/apps/APPNAME/conf/certs/app.example.com.crt"
    SSLCertificateKeyFile "/opt/bitnami/apps/APPNAME/conf/certs/app.example.com.key"
    ...        
    
  • If you used the httpd-vhosts.conf file for the application, check that the installdir/apache2/conf/bitnami/bitnami-apps-vhosts.conf file includes the httpd-vhosts.conf file for your application. It should include a line like the one below.

    Include "installdir/apps/APPNAME/conf/httpd-vhosts.conf"
    

    If it does not, add the line above to the installdir/apache2/conf/bitnami/bitnami-apps-vhosts.conf file, replacing the APPNAME placeholder with the correct directory name for your application.

  • After modifying the Apache configuration files, restart Apache to apply the changes.

Last modification November 14, 2019