1

I have a site on apache web server. I have a file structure like this.

test.php
accessA.php
otherfiles.php

I want to add restrict access to test.php file for all user and for all file .for example if a user enter the http://site/test.php as url or a file or a user want to access the site/test.php directory the error message show and the user can not access the testA.php. but I want allow only accessA.php file for access the test.php file with include statement like this. accessA.php

<?php
include_once 'test.php' ;
?>

In other words I want allow access the test.php file only for accessA.php. how I do that??

can I use open_basedir ??

3
  • In the first lines of text.php test a user account against a set of known permissions. If the user does not have the proper permissions, send a 303. Commented Feb 21, 2014 at 23:05
  • can I use open_basedir ?? Commented Feb 21, 2014 at 23:07
  • I don't get what are you really asking. Please make the question more clearer. Commented Feb 21, 2014 at 23:11

2 Answers 2

1

You cannot use open_basedir, it's a configuration who permit to chroot the apache's instance (who make the root of the website at the level where you definined it in open base dir variable) The better way to deny the acces to some page is to do a htaccess

Sign up to request clarification or add additional context in comments.

Comments

1

put on top the test.php file this line :

if($_SERVER['SCRIPT_NAME']=='test.php')die('not allowed');

You can deny access by htaccess rules too.

RewriteRule ^test.php$ - [R=404,L]

2 Comments

in this case how I can access to test.php with accessA.php ??
if you include test.php from accessA.php the script name will be accessA.php not test.php so you will be able to include test.php

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.