General Overview
I've been creating this really nice .htaccess file with a bunch of settings that work great so far. I am wondering if it is possible, now, to allow access to files through flat links only while denying access to the same files directly.
Explanation & Current Settings
To better present this question consider the following:
I have a file: i.e. myFile.php
Which is in a subfolder: i.e. my/path/to/file/
The file's full path would then be my/path/to/file/myFile.php
Accessing this file through a URL, one would write: my.domain.com/my/path/to/file/myFile.php
In my .htaccess file, I have written a rewrite rule, similar to the following line of code (preceded by some RewriteCond
's that ensure conditions are met regarding the host and filenames respectively):
RewriteRule ^home$ \/my\/path\/to\/file\/myFile.php [NC,L]
This means that someone trying to get to my page my/path/to/file/myFile.php
can simply write my.domain.com/home
instead of the ugly path my.domain.com/my/path/to/file/myFile.php
.
Question & Preferred Outcome
What I am asking is:
Is it possible to block access to myFile.php
if a person or machine attempts to go to my.domain.com/my/path/to/file/myFile.php
, all the while allowing access to the file through my.domain.com/home
?
Any help regarding this is greatly appreciated