我目前在许多不同的文件夹和子文件夹中都有 PDF。
我正在寻找一种使用 .htaccess 使任何 pdf URL 显示为好像位于同一文件夹中的方法。
这个:https://example.com/random/random/filename.pdf
为此:https://example.com/pdf/filename.pdf
到目前为止我已经尝试过了
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ([^\/]+\.pdf)$ /pdf/$1 [NC,L,R=301]
这似乎没有做任何事情。
谢谢。
尝试这个解决方案
RewriteEngine On
RewriteRule ^pdf/([^\/]+\.pdf)$ random/random/$1 [NC]
它对我有用。 对 .htaccess 文件进行这些更改后,重新启动您的网络服务器。