Reputation: 5374
A client had his PDF files uploaded to the CMS' root over month. I'ld like to move all PDFs into a new subfolder to keep the root clean. Problem now is they absolute linked these PDFs in many articles. Is there a way I can redirect all (and only) links to a root PDF to their new destination?
Additionally, I tried do my homeworks but couldn't find a comprehensive guide about .htaccess and ask you to share the best gem from you bookmarks.
Upvotes: 2
Views: 422
Reputation: 785276
You can use this rule in your root .htaccess:
RewriteEngine on
RewriteRule ^([^./]+\.pdf)$ /subfolder/$1 [L,NC,R=301]
Upvotes: 1
Reputation: 2596
This should do it:
RewriteEngine on
RewriteBase /
RewriteRule ^([^/]*?).pdf$ newpath/$1.pdf
Upvotes: 1