2012-04-23 318 views
0

我想从一个特定的文件夹(这里toto)我所有的PDF文件重定向到另一个文件夹(这里tata)的根目录,如:重定向301 htaccess的

www.mywebsite/toto/fic1.pdf     -> www.mywebsite/tata/ 
www.mywebsite/toto/fic2.pdf     -> www.mywebsite/tata/ 
www.mywebsite/toto/fic3.pdf     -> www.mywebsite/tata/ 
www.mywebsite/toto/fic4.pdf     -> www.mywebsite/tata/ 
www.mywebsite/toto/sousDossier/fic4.pdf  -> www.mywebsite/tata/ 

我写每一条线文件,但它是不漂亮...

RedirectPermanent /toto/fic1.pdf http://www.mywebsite/tata/ 

回答

1
RewriteEngine On 
RewriteRule /?toto/.*\.pdf$ /tata/ [R=301,L]
+0

谢谢,但它会重定向www.monsite/toto/a.pdf到/tata/a.pdf不是吗?我只想要/ tata /没有a.pdf – Max 2012-04-23 14:23:04

+1

不,它会重定向到www.yoursite.com/tata/ – vmeln 2012-04-23 14:25:57

+0

...是否确定?它不起作用 – Max 2012-04-23 14:26:31

0

启用mod_rewrite的,并通过httpd.conf的.htaccess,然后把这个代码在你.htaccessDOCUMENT_ROOT目录:

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 
RewriteBase/

RewriteRule ^toto/[^.]+\.pdf$ tata/ [R=301,L,NC]