문제

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.

도움이 되었습니까?

해결책

You can use this rule in your root .htaccess:

RewriteEngine on

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

다른 팁

This should do it:

RewriteEngine on
RewriteBase /
RewriteRule ^([^/]*?).pdf$ newpath/$1.pdf
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top