且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何阻止对.html文件的直接访问? (.htaccess)

更新时间:2023-12-03 07:57:04

尝试以下操作:在index.html而不是notfound.html上重定向

Try this : redirect on index.html instead of notfound.html

RewriteEngine On

RewriteCond %{HTTP_REFERER} !^http://www.mywebsite.com/index.html
RewriteRule .*\.html$ index.html
RewriteCond %{HTTP_REFERER} ^http://www.mywebsite.com/index.html
RewriteRule (.*)\.html$ $1.html

在其他.htaccess中的图像目录中:

In images directory in other .htaccess :

options -indexes
ErrorDocument 403 http://www.mywebsite.com/index.html

但是您为什么想要去做这个? ;)

But why do you wish to do this? ;)