Reputation: 2272
Simply, I am trying to make it so if a user goes to a folder, it will give a 404 Error
. Problem is, it does not seem to work!
Here is my file setup:
- postin
- mail
- yourmail.php
- profiles
- viewprofile.php
- .htaccess
- error.php
Then simply I am adding this to my .htaccess:
RewriteRule ^mail/ - [L,R=404]
ErrorDocument 404 error.php
I thought by adding this code that if a user typed in the URL .../postin/mail/
that it would take the user to the 404 error.php page. That does not seem the be the case though, it will just bring up the directory page for .../postin/mail/
. So my question is, how do I raise the 404 error when a user goes to a folder (directory)?
If you would like my full .htaccess it is here:
Options +FollowSymLinks
RewriteEngine on
# skip all files and directories from rewrite rules below
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule search/(.+)/?$ search.php?query=$1 [NC,L]
RewriteRule search/?$ search.php [NC,L]
RewriteRule register/?$ registerpage.php [NC,L]
RewriteRule login/?$ loginpage.php [NC,L]
RewriteRule home/?$ home.php [NC,L]
RewriteRule users/?$ users.php [NC,L]
RewriteRule error/?$ error.php [NC,L]
RewriteRule ^mail/ - [L,R=404]
ErrorDocument 400 http://localhost/postin/error
ErrorDocument 401 http://localhost/postin/error
ErrorDocument 403 http://localhost/postin/error
ErrorDocument 404 http://localhost/postin/error
ErrorDocument 500 http://localhost/postin/error
ErrorDocument 502 http://localhost/postin/error
ErrorDocument 504 http://localhost/postin/error
<Files .htaccess>
order allow,deny
deny from all
</Files>
Upvotes: 0
Views: 54
Reputation: 41219
You can use :
DirectoryIndex /errorpage.php
This should be the ver first line in your htaccess
Upvotes: 1