AlphalogicZ

  • Home
  • Services
  • Work
  • Blogs
  • Contact
  • Home
  • 2021
  • September
December 5, 2025

Month: September 2021

Apache, non-WWW to WWW (HTTPS/Secure)

Thursday, 30 September 2021 by AlphalogicZ

Here is my “normal” config file and just “gets the task done”.

Here’s my Updated File

<IfModule mod_ssl.c>
  <VirtualHost *:443>
    ServerAdmin admin@domain.co.uk

    ServerName www.domain.co.uk
    ServerAlias domain.co.uk

    DocumentRoot /var/www/html/domain

    <Directory /var/www/html/domain/>
      Options FollowSymLinks
      AllowOverride All
      Require all granted

      # Redirect non-www to www
      RewriteEngine On

      RewriteCond %{HTTP_HOST} !^www\. [NC]
      RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Include /etc/letsencrypt/options-ssl-apache.conf
    SSLCertificateFile /etc/letsencrypt/live/domain.co.uk/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/domain.co.uk/privkey.pem
  </VirtualHost>
</IfModule>

Where I have got the “Redirect non-www to www are the few lines where I have tried to make the changes done.

CodingPHPPHP ProgrammingServerUbuntu
Read more
  • Published in Apache, PHP Programming, Server, Ubuntu
No Comments

Categories

  • Apache
  • PHP Programming
  • Server
  • Ubuntu

Recent Posts

  • How To Set Up Password Authentication with Apache on Ubuntu 14.04

    When setting up a web server, there are often s...
  • Apache, non-WWW to WWW (HTTPS/Secure)

    Here is my “normal” config file and just “gets ...
  • How to set Timezone in Laravel

    Open the file app.php file present in config di...
  • Write Clean and Secure PHP Code

    I’m reading Clean Code, a technical book which ...

Archives

  • October 2021
  • September 2021
  • August 2021
  • September 2020

Pages

  • Blogs
  • Contact
  • home
  • Services
  • test-blog
  • Work
TOP