如何直接拒绝浏览器中的url访问,但允许使用index.html

问题描述 投票:0回答:1

我在一个目录中有多个html文件,例如home.html,welcomec.html,login.html和index.html。

从浏览器中,我可以直接访问https://localhost/demo/welcome.htmlhttps://localhost/demo/login.html之类的所有文件。如何防止这种情况?

我只希望从浏览器访问index.html,并允许从index.html进行另一个html访问。

apache .htaccess mod-rewrite web-hosting httpd.conf
1个回答
0
投票

您可以允许index.html并使用下面的/var/www/html位置标记禁用所有文件:

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all denied
<Files "index.html">
Require all granted
    </Files>
</Directory>

Refer link for more information

我不确定它是否允许通过index.html访问文件。您可以测试上述配置。

© www.soinside.com 2019 - 2024. All rights reserved.