1

I already disabled directory browsing using this method How do I disable directory browsing? .. Now, is it possible for me to redirect it to a particular page?

Ex. mysite.com/subdirectory/another_directory/ to mysite.com/sorry.php


okay, i made it.

i just need to do this ..

RewriteEngine on
RewriteBase /client/
php_value upload_max_filesize 15M
php_value post_max_size 15M
#Options -Indexes

RewriteRule ^downloads/files/?$ /sorry.php [L,NC,R=302]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]

and it works!

Community
  • 1
  • 1
user3258603
  • 149
  • 2
  • 17

2 Answers2

1

Your .htaccess:

php_value upload_max_filesize 15M
php_value post_max_size 15M
#Options -Indexes

RewriteEngine on
RewriteBase /client/

RewriteRule ^downloads/files/?$ /sorry.php [L,NC,R=302]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php [L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • it doesn't work.. i still get the 403 forbidden error and i am not redirected to sorry.php – user3258603 Feb 12 '14 at 13:43
  • Can you show your current .htaccess? You need to remove `directory browsing disabling`. – anubhava Feb 12 '14 at 13:45
  • `RewriteEngine on RewriteBase /client/ RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME}\.php -f RewriteRule ^(.*)$ $1.php php_value upload_max_filesize 15M php_value post_max_size 15M Options -Indexes RedirectMatch 301 ^/downloads/files/ /sorry.php` if i am going to remove `Options -Indexes` .. i can browse now the directory files – user3258603 Feb 12 '14 at 13:58
  • also, when i do what you answer above all my page like index.php as index and edit.php as edit i am now getting 404 not found – user3258603 Feb 12 '14 at 14:08
  • it works.. try to view my updated question... i just need to add `RewriteEngine on` – user3258603 Feb 12 '14 at 14:13
  • Yes I assumed `RewriteEngine On` is already there from your comments. Consider marking the answer as accepted now. – anubhava Feb 12 '14 at 14:14
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/47327/discussion-between-user3258603-and-anubhava) – user3258603 Feb 12 '14 at 14:19
0

In your .htaccess file write:

Options -Indexes
ErrorDocument 403 /sorry.php [R=301,L]
moonwave99
  • 21,957
  • 3
  • 43
  • 64