阻止通过.htaccess直接访问php和html页面的URL [英] prevent direct URL access to php and html pages via .htaccess
问题描述
我知道可以通过.htaccess规则阻止直接URL访问,但是我对元字符或转义一无所知.
I know direct URL access can be prevented via .htaccess rules but I don't know much about meta-chars or escaping.
这些是我的xammp/htdocs文件夹中的文件,可使用本地主机:
these are the files in my xammp/htdocs folder, accessed using localhost:
index.php
createScheme.php
several someother.php
我希望仅对index.php和createScheme.php启用直接访问,并且应阻止所有其他页面直接访问.
I want direct access to be enabled only for index.php and createScheme.php and all others pages should be blocked against direct access.
请帮助!
推荐答案
此 .htaccess
文件仅允许用户打开 index.php
.尝试访问任何其他文件将导致403错误.
This .htaccess
file will only allow users to open index.php
. Attempts to access any other files will result in a 403-error.
Order deny,allow
Deny from all
<Files "index.php">
Allow from all
</Files>
如果您还想对某些文件使用身份验证,则只需在示例末尾添加当前文件中的内容即可.
If you also want to use authentication for some of the files, you may simply add the content from your current file at the end of my example.
这篇关于阻止通过.htaccess直接访问php和html页面的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!