我有这棵树:
libs/
html/
app/
uploads/
files/
images/
male.png
female.png
.htaccess
download.php
.htaccess
index.php
/。htaccess具有以下内容:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -Indexes
</IfModule>
RewriteEngine On
RewriteRule ^ index.php [END,L]
</IfModule>
我希望/uploads/.htaccess访问:
重定向到download.php
重定向404
示例:
www.example.com/uploads - redirect 404
www.example.com/uploads/files - redirect 404
www.example.com/uploads/images- redirect 404
www.example.com/uploads/.htaccess - redirect 404
www.example.com/uploads/download.php - redirect 404
www.example.com/uploads/nonexistentfile - redirect 404
www.example.com/uploads/images/male.php - redirect download.php
www.example.com/uploads/images/female.php - redirect download.php
答案 0 :(得分:0)
下面的讨论应该对您有所帮助: Redirect requests only if the file is not found?
# If requested resource exists as a file or directory go to it
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule (.*) - [L]
#Alternatively the code above redirects where you want
# Else rewrite requests for non-existent resources to /404.php
RewriteRule (.*) /404.php?q=$1 [L]
答案 1 :(得分:0)