.htaccess重定向整个目录,pdf文件除外

时间:2013-10-24 19:17:01

标签: .htaccess redirect

我正在尝试将目录2(/directory1/directory2/)中的所有内容(PDF文件除外)重定向到静态URL。这可能吗?

1 个答案:

答案 0 :(得分:2)

是的,这是可能的。将此代码放在root .htaccess

RewriteEngine On

# it doesn't end with .pdf
RewriteCond %{REQUEST_URI} !\.pdf
# URI starts with /directory1/directory2 then redirect
RewriteRule ^directory1/directory2/(.*)$ /some-where/$1 [L,NC,R]