logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Issues with "Download" when using https/443
Author
aadesilva



Joined: 26 May 2022
Posts: 4
Location: PH

PostPosted: Thu 26 May '22 13:32    Post subject: Issues with "Download" when using https/443 Reply with quote

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: 305
Location: UK

PostPosted: Thu 26 May '22 22:03    Post subject: Reply with quote

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

PostPosted: Fri 27 May '22 7:29    Post subject: Reply with quote

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: 149
Location: Schömberg, Baden-Württemberg, Germany

PostPosted: Fri 27 May '22 17:47    Post subject: Reply with quote

According to documentation
Code:
Redirect permanent "/" "https://mysite.com/"

redirects the exact URL to another URL. So all other URLs will not be redirected... Sad

Using tangent's solution redirects all http-URLs to their https-counterpart. Very Happy

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

PostPosted: Mon 30 May '22 7:43    Post subject: Reply with quote

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: 149
Location: Schömberg, Baden-Württemberg, Germany

PostPosted: Mon 30 May '22 21:12    Post subject: Reply with quote

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

PostPosted: Thu 02 Jun '22 7:14    Post subject: Reply with quote

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


Joined: 19 Jan 2006
Posts: 7288
Location: Germany, Next to Hamburg

PostPosted: Tue 07 Jun '22 11:57    Post subject: Reply with quote

You can change the HTML links with https://httpd.apache.org/docs/2.4/mod/mod_sed.html
Back to top


Reply to topic   Topic: Issues with "Download" when using https/443 View previous topic :: View next topic
Post new topic   Forum Index -> Apache