简体   繁体   中英

.htaccess how can i allow access to pages only through the index.php page

In my folder i have

index.php user.php header.php writer.php footer.php

i want the user to access index.php only and links to the other.php pages are in index.php

if user enters header.php in address bar he get forbidden error.

Thanks

Remove those files from the Root folder. and place them in a folder not accessible to the user.

index.php stays in the root.

example: html is the root folder accessed by http://example.com

/var/www/html/index.php

and the other files go in a seperate directory not accessible through the url.

Example:

/var/www/includes/user.php
/var/www/includes/header.php
...

you can access those files with the include going back one directory. Example

index.php
<?php

include '../includes/users.php';

?>

This will make your website more secure.

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