I'm running a small VPN server where each user has his own static IP.
I set up an Apache server in order to host files for each of them and instead of using a new registration system, I wanted to take advantage of those static IPs.
So I thought I could use mod_rewrite to achieve that and wrote this snippet:
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} 10\.8\.0\.11
RewriteRule ^(.*)$ user1/ [L]
If user1, who has the IP 10.8.0.11, tries to reach http://10.8.0.1/
, he's properly redirected to the appropriate subfolder http://10.8.0.1/user1/
.
If user1 tries to reach any other subfolder, he's also properly redirected to his own subfolder.
Though there are some issues with this setup:
- if there's an index file on that folder, I end up with an internal error
- if there's any other file, I cannot download/run it
Is there any way I can overcome this?
I mean, locking a user on a specific subfolder based on his IP and allowing him to browse that folder (viewing a website, retrieving files...).