这是我有安全详细信息的路径,例如,http://localhost/application/secure_details
secure_details
是我的机密文件上传的文件夹
知道上述URL的第三方可以获得特定的详细信息,
这是不允许的。如果用户直接访问这个特定的URL,我需要重定向到error_page
。
使用mod_rewrite
,将其添加到根.htaccess
:
RewriteEngine on
RewriteBase /
RewriteRule ^application/secure_details/?.*?$ /error.html [L,R=301]
此外,将此.htaccess
文件添加到secure_details
目录:
Deny from all
首先需要在apache中启用rewrite模块来使用htaccess
。之后,您可以使用以下脚本来确保您的url的安全
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteRule ^/*application/secure_details error.php[L,NC,QSA]
在error.php
文件中,您可以编写错误消息