Author |
|
aadesilva
Joined: 26 May 2022 Posts: 4 Location: PH
|
Posted: Thu 26 May '22 13:32 Post subject: Issues with "Download" when using https/443 |
|
|
Hi everyone. I'm new here. Looking to get some help.
As per security recommendation, we need to configure our webserver with SSL certificates. I was able to do it and all http traffic is redirected to https. All seems to work fine except for one functionality, download.
The links provided in the download button is still using http and when I'm clicking on it, nothing happens. But when I copy the download link and replace it with https, it's downloading fine.
Just wondering if anyone encountered similar behavior with SSL setup? Thanks! |
|
Back to top |
|
tangent Moderator
Joined: 16 Aug 2020 Posts: 342 Location: UK
|
Posted: Thu 26 May '22 22:03 Post subject: |
|
|
I think you have a couple of options here.
1) Have Apache redirect all non-secure requests to the equivalent secure one.
2) Get the various download links updated to either be https or site relative, i.e. simply start with a /
Option 1) has the benefit that it covers any non-secure links squirreled away in the site, as well as people's non-secure bookmarks, etc.
The following sample VirtualHost code placed before your secure site configuration should cover off option 1).
Code: | # Define default virtual host
#
<VirtualHost *:80>
# Enable mod_rewrite
#
RewriteEngine On
# Check for a non-secure HTTP request and if found redirect to HTTPS equivalent.
#
RewriteCond %{HTTPS} off
RewriteRule ^/(.*)$ https://%{HTTP_HOST}/$1 [L,NE,QSA,R]
</VirtualHost>
# Define secure site virtual host
#
<VirtualHost *:443>
# Your secure site configuration...
#
</VirtualHost> |
Option 2) should be undertaken by the people responsible for the site content. |
|
Back to top |
|
aadesilva
Joined: 26 May 2022 Posts: 4 Location: PH
|
Posted: Fri 27 May '22 7:29 Post subject: |
|
|
Hi Tangent,
Thanks for your reply.
I already have the same setup except for the rewrite option which is not working for me.
I used below instead of rewrite and it's redirecting all traffic to https with just the exception of download function.
Code: | Redirect permanent "/" "https://mysite.com/" |
|
|
Back to top |
|
mraddi
Joined: 27 Jun 2016 Posts: 152 Location: Schömberg, Baden-Württemberg, Germany
|
Posted: Fri 27 May '22 17:47 Post subject: |
|
|
According to documentation
Code: | Redirect permanent "/" "https://mysite.com/" |
redirects the exact URL to another URL. So all other URLs will not be redirected...
Using tangent's solution redirects all http-URLs to their https-counterpart.
If you can't use mod_rewrite you may work with something like
Code: | RedirectMatch ^/(.*)$ https://mysite.com/$1 | .
Of couse you have to place the redirects where it is only valid/visible for unencrypted http-traffic and not for the already encrypted https-traffic. |
|
Back to top |
|
aadesilva
Joined: 26 May 2022 Posts: 4 Location: PH
|
Posted: Mon 30 May '22 7:43 Post subject: |
|
|
Thanks @mraddi but still not working. Other than the download link which is still has http on the link, the rest are working fine.
Still can't figure it out. But when I try to copy the link and directly paste it in the browser, it's working. |
|
Back to top |
|
mraddi
Joined: 27 Jun 2016 Posts: 152 Location: Schömberg, Baden-Württemberg, Germany
|
Posted: Mon 30 May '22 21:12 Post subject: |
|
|
Please ensure that mod_rewrite is loaded/enabled.
With Linux you can check with "a2query -m"
In addition check that your Apache-config is valid/correct ("httpd -t" and "httpd -S") |
|
Back to top |
|
aadesilva
Joined: 26 May 2022 Posts: 4 Location: PH
|
Posted: Thu 02 Jun '22 7:14 Post subject: |
|
|
mraddi wrote: | Please ensure that mod_rewrite is loaded/enabled.
With Linux you can check with "a2query -m"
In addition check that your Apache-config is valid/correct ("httpd -t" and "httpd -S") |
Thanks, mraddi. Yes mod_rewrite is enabled.
I just found out that mod_rewrite or redirect is not working with links coded via <a href>. Been snooping around the net and can't find anything that would make it work.
It's working though when I'm copying the link and pasting it to new tab, it will redirect to https but not working when I'm directly clicking on the link. |
|
Back to top |
|
James Blond Moderator
![](images/avatars/3066243e8d00d4770e.gif)
Joined: 19 Jan 2006 Posts: 7342 Location: Germany, Next to Hamburg
|
|
Back to top |
|