Вопрос

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