0

I'm somewhat of a Website noob myself. We are currently running Wordpress for our Website. Now I am tasked with the following:
A page to search, download and access certain PDF-documents but only for restricted IP-addresses. The page should be reacheable through the same domain name as the website is currently running on - let's call it my-domain.com.
Now my question is, do you guys know a certain wordpress plugin or some other tool that i can use for this task? I would really like to simply create another page for my website e.g. my-domain.com/downloads that can only be visited by these whitelisted IP-ranges.
I'd really appreciate your help and or comments on the whole thing :)

Regards,
Ole

OHithere
  • 33
  • 4
  • What web server are you using? You can also add the corresponding tag to your question. – Piotr P. Karwasz Dec 12 '19 at 19:32
  • Hi, I'm using apache2. I'll add the tag. – OHithere Dec 12 '19 at 19:34
  • I think you con probably do that with a .htaccess file in the directory you want to protect. I am trying to recover from a different fiasco, and so can't test, but someone will will show you how to do that if I'm right. – Bob Brown Dec 12 '19 at 19:57
  • I couldn't stand it. I had to look. You will find an answer here:https://stackoverflow.com/a/4400412/3718204 Put the contents in a file called .htaccess (note the leading dot) in the directory you want to protect. Test before putting sensitive documents in there. (I didn't make it an answer to this question because I didn't write it.) Be sure the .htaccess file is owned by root so it can't be corrupted. – Bob Brown Dec 12 '19 at 20:25
  • For Apache 2.4 and up, see this answer: https://stackoverflow.com/a/37865837/3718204 – Bob Brown Dec 12 '19 at 20:27
  • First of all, thank you Bob! You brought me on the right track on what to search for! I found this article which I think addresses my exact problem: https://serverfault.com/questions/725214/apache-2-4-restrict-url-to-certain-ips. I'll try this out this weekend and give a response whether it worked. – OHithere Dec 13 '19 at 09:28

1 Answers1

0

So, as it turns out I tried some things and found a working solution: It ist possible to add these Rewrite-rules to the apache vhost-config:

    RewriteEngine On
    RewriteCond %{REQUEST_URI} ^\my-url$
    RewriteCond %{REMOTE_ADDR} ^xxx\.xxx\.xxx\.[0-9]{1,3}$ #use regex for ip-range
    RewriteRule ^(.*)$ redirect/url [R=301,L]

Thank your for your comments and help to get on the right track :)

OHithere
  • 33
  • 4