这个htaccessRewriteRule
仅重写.pdf
不使用/年/月/可以如下所示
RewriteRule ^wp-content/uploads/([0-9]+)/([0-9]+)/(.+?)$ /wp-content/uploads/$3.pdf [L,R=301]
您应该在WordPress的规则之前添加此项,因此它将在它们之前进行评估,从而生成一个。htaccess文件,如下所示
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-content/uploads/([0-9]+)/([0-9]+)/(.+?)\\.pdf$ /wp-content/uploads/$3.pdf [L,R=301]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress