简体   繁体   中英

prevent direct URL access to php and html pages via .htaccess

I know direct URL access can be prevented via .htaccess rules but I don't know much about meta-chars or escaping.

these are the files in my xammp/htdocs folder, accessed using localhost:

index.php
createScheme.php
several someother.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.

Please help!

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.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM