I want my users to only access my php files, if they try to access the folders I want to include my page 404 file

后端 未结 1 882
[愿得一人]
[愿得一人] 2021-01-21 08:48

I have my query string to include my pages, in my homepage like you see below and it is working fine, Im including my pages fine.

But something wrong is

相关标签:
1条回答
  • 2021-01-21 09:20

    There is an easier solution.

    Add this line to the beginning of your .htaccess file:

    Options -Indexes
    

    This way, you won't be able to see the folder contents.


    EDIT: htaccess rule solution (which is in website folder)

    ErrorDocument 404 /website/inc/404.php
    
    RewriteEngine On
    RewriteBase /website/
    
    RewriteRule ^teachers/$ - [R=404,L]
    
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?url=$1 [L]
    
    0 讨论(0)
提交回复
热议问题