I want to block direct access to multiple files, but being able to access in index.html
For example: I want to block access to all the files located in " http://www.mywebsite.com/pages
" such as " contact.html
" " about.html
"... and only be accessed by "index.html" ( http://www.mywebsite.com/
)
and if possible, to block access to images folder ( http://www.mywebsite.com/images
) but still being able to use the images in "index.html"
I want to redirect to home page ( index.html
) or send a 404 status code when these files are directly accessed... I have a 404 not found page called " notfound.html
"
Files:
index.html
pages (contains few .html pages used as links in index.html
) images (contains images used in index.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
In images directory in other .htaccess :
options -indexes
ErrorDocument 403 http://www.mywebsite.com/index.html
But why do you wish to do this? ;)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.