My SSL server has a directory structure like the following:
[tt]
SSL Root
- Some Directory #1
- Some Directory #2
- ...
- JS Files
[/tt]
Everything works fine, authentication is working, et. al.
The html pages in the subdirectories use common JavaScript code, which resides in the "JS Files" subdirectory. This repository contains scripts that are common to all pages (e.g., no right-mouse click), so I include a SCRIPT directive in each page to point to the source found in "JS Files".
Having said all of this, I would like to know how to keep my access (as configured) to the SSL directories, but restrict it to the "JS Files" directory.
Ideally, I would like to prevent the user from downloading the JavaScript files. Is there a way to configure Apache to allow the pages to read the .js files, but prevent the user from accessing them directly? I.e., as it stands, the user can link directly to "https://[My Host]/JS Files/Some java script.js" and download/view the JavaScript file. I would like to prevent this.
Everything that I have tried thus far has only disabled the html pages from reading the script files (e.g., re-enabling right-mouse click).
I tried adding the following to my SSL VirtualHost:
[tt]
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https://[My SSL Host]/[SSL Root]/.*$
RewriteCond %{REQUEST_URI} ^(.*)\.js$
RewriteRule ^(.*) - [F,L]
[/tt]
This prevents the user from downloading/viewing the scripts in that directory; but, it also prevents the html pages from reading and executing the JavaScript files.
Can someone help? I am sure it's probably some simple rewrite rule, but I am pretty novice at server configuration and the rewrite rules tend to get me into trouble.
I have already looked at Stopping people saving images (Thread215-620990); however, since the JavaScript is not viewable, I am assuming that there is some way to protect it from being downloaded.
Thank you in advance for your help.
[tt]
SSL Root
- Some Directory #1
- Some Directory #2
- ...
- JS Files
[/tt]
Everything works fine, authentication is working, et. al.
The html pages in the subdirectories use common JavaScript code, which resides in the "JS Files" subdirectory. This repository contains scripts that are common to all pages (e.g., no right-mouse click), so I include a SCRIPT directive in each page to point to the source found in "JS Files".
Having said all of this, I would like to know how to keep my access (as configured) to the SSL directories, but restrict it to the "JS Files" directory.
Ideally, I would like to prevent the user from downloading the JavaScript files. Is there a way to configure Apache to allow the pages to read the .js files, but prevent the user from accessing them directly? I.e., as it stands, the user can link directly to "https://[My Host]/JS Files/Some java script.js" and download/view the JavaScript file. I would like to prevent this.
Everything that I have tried thus far has only disabled the html pages from reading the script files (e.g., re-enabling right-mouse click).
I tried adding the following to my SSL VirtualHost:
[tt]
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^https://[My SSL Host]/[SSL Root]/.*$
RewriteCond %{REQUEST_URI} ^(.*)\.js$
RewriteRule ^(.*) - [F,L]
[/tt]
This prevents the user from downloading/viewing the scripts in that directory; but, it also prevents the html pages from reading and executing the JavaScript files.
Can someone help? I am sure it's probably some simple rewrite rule, but I am pretty novice at server configuration and the rewrite rules tend to get me into trouble.
I have already looked at Stopping people saving images (Thread215-620990); however, since the JavaScript is not viewable, I am assuming that there is some way to protect it from being downloaded.
Thank you in advance for your help.