我有一个网站,example.com
我也有以下子目录:
example.com/dir1/
example.com/dir2/
example.com/dir3/
现在,如果他们尝试访问,我希望将访问者重定向到404:
example.com/dir1 /
但以防万一,当他们尝试访问时:
example.com/dir1/example.php
下面是我的.htaccess:
RewriteEngine On
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php
RewriteRule ^index\.php$ / [L,R=301]
Options -Indexes
在htaccess之上,当我尝试按以下方式访问任何子目录时,出现默认错误:
Access forbidden!
You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.16 (Win32) OpenSSL/1.0.1p PHP/5.6.12
尝试在您的.htaccess文件中使用它!
ErrorDocument 404 /filenotfound.html
IndexIgnore *
尝试:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L,R=404]