简体   繁体   中英

Access file via masked url only .htaccess

I have a domain which contains some php files, I have setup url masking like this...

RewriteEngine on
RewriteCond %{REQUEST_URI} /ht.php$
RewriteRule .* /folder/location/user.php [L]

when the user accesses ht.php they see user.php

which is what I wanted but I also want to now block direct access to user.php so they can access it through ht.php but not directly

now I have tried blocking direct access to user.php via htaccess but this also blocks access via ht.php

Is there a way I can let the user access the file using the masked url ht.php but block direct access to user.php using htaccess ?

I think you have to write custom code to check whether the file accessed from ht.php. Else display a 404.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM