Search code examples
apachenassynology

how to setup a securised personal appache website on my synology NAS?


I recently bought a synology ds918+ and I would like to create a web site I created it using the web station and apache 2.4 package but I'd prefer my website to be on https than http and would like to be able to automatically be on https, 443 port when I enter the link to my web site. But didn't found any clear tutorial on how to do it, how can I do this ?


Solution

  • I had the same problem and found a good manual. What you need is a .htaccess file in the root of the web page with following content:

    #turn on url rewriting 
    RewriteEngine On
    
    #reroute http to https and website.com to www.website.com
    RewriteCond %{HTTP_HOST} ^website\.com$ [NC]
    RewriteRule ^(.*)$ http://www.website.com/$1 [R=301,L]
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
    

    Just replace "website" and ".com" with your names.

    You can also add the following:

    ErrorDocument 404 /404.htm
    

    Hope that helps