0

我正在尝试重定向一个网址,例如:

http://www.example.co.uk/pdfs/example-file.pdf

http://www.example.co.uk/files/example-file.pdf

http://www.example.co.uk/documents/example-file.pdf

到基本域,http://www.example.co.uk/

# PDFs on old site, redirect them
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^/?pdf/(.*)$ http://www.example.co.uk/$1 [R=301,L]
    RewriteRule ^/?files/(.*)$ http://www.example.co.uk/$1 [R=301,L]
    RewriteRule ^/?documents/(.*)$ http://www.example.co.uk/$1 [R=301,L]
</IfModule>
# END PDFs on old site, redirect them

我在哪里错了?

4

1 回答 1

1

正确的规则是:

# PDFs on old site, redirect them
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^(/?pdfs/.*)$ http://www.example.co.uk/$1 [R=301,L]
    RewriteRule ^(/?files/.*)$ http://www.example.co.uk/$1 [R=301,L]
    RewriteRule ^(/?documents/.*)$ http://www.example.co.uk/$1 [R=301,L]
</IfModule>
# END PDFs on old site, redirect them
于 2013-07-26T16:37:22.593 回答