Sapnesh Naik
Sapnesh Naik

Reputation: 11656

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!

Upvotes: 0

Views: 3912

Answers (1)

Rohit Goyani
Rohit Goyani

Reputation: 1256

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.

Upvotes: 2

Related Questions