是否可以在浏览目录后将某人重定向到页面

时间:2014-02-12 13:16:52

标签: php apache .htaccess mod-rewrite redirect

我已使用此方法How do I disable directory browsing?禁用目录浏览。 现在,我可以将其重定向到特定页面吗?

实施例。 mysite.com/subdirectory/another_directory/mysite.com/sorry.php


好吧,我做到了。

我只需要这样做..

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]

它有效!

2 个答案:

答案 0 :(得分:1)

你的.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]

答案 1 :(得分:0)

.htaccess文件中写:

Options -Indexes
ErrorDocument 403 /sorry.php [R=301,L]