[英]How to deny access to a url within htaccess
How can I deny direct access to a URL through .htaccess
file?如何拒绝通过.htaccess
文件直接访问 URL?
The URL for example is例如网址是
www.example.com/course/reset-password
The file is located within a course
folder and the alternative and all files in that folder can allow direct access with exception of reset-password.php
.该文件位于course
文件夹中,该文件夹中的替代文件和所有文件都可以允许直接访问,但reset-password.php
除外。
Inside corse/.htacccess
you can have just this rule to block access:在corse/.htacccess
您可以使用此规则来阻止访问:
RewriteEngine On
RewriteCond %{THE_REQUEST} /reset-password [NC]
RewriteRule ^ - [F]
If you wish to deny access to a specific file (as opposed to a URL) then consider using mod_authz_core (Apache 2.4) instead of mod_rewrite.如果您希望拒绝访问特定文件(而不是 URL),请考虑使用 mod_authz_core (Apache 2.4) 而不是 mod_rewrite。 For example:例如:
<Files "reset-password.php">
Require all denied
</Files>
This has less chance of being overridden than mod_rewrite.这比 mod_rewrite 被覆盖的可能性更小。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.