Question

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.

Était-ce utile?

La solution

You can use this rule in your root .htaccess:

RewriteEngine on

RewriteRule ^([^./]+\.pdf)$ /subfolder/$1 [L,NC,R=301]

Autres conseils

This should do it:

RewriteEngine on
RewriteBase /
RewriteRule ^([^/]*?).pdf$ newpath/$1.pdf
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top