[英]Redirect directory but exclude a subdirectory
因此,我們有一個WordPress網站,我們在其中使用插件將wp-content / uploads目錄中的所有文件推送到Amazon S3。 但是,我們使用視頻插件,該插件需要使用temp文件夾中的uploads目錄來生成視頻縮略圖。
由於我們有一個重寫規則(如下所示)將/ wp-content / uploads重定向到相關的S3地址,這對於使后端正常運行至關重要,因此這會導致臨時文件夾出現問題。
RedirectPermanent /wp-content/uploads/ [amazonbucketurl]/wp-content/uploads/
我們需要一個重定向規則,該規則可以放在.htaccess文件中,並且將/ wp-content / uploads / thumb_tmp從/ wp-content / uploads的覆蓋重定向規則中排除。
任何幫助都會很棒!
嘗試以下規則:
RedirectPermanent /wp-content/uploads/(?!thumb_tmp).* [amazonbucketurl]/wp-content/uploads/
此處(?!thumb_tmp)
用於從重寫中排除thumb_tmp
子文件夾。
最終成功了!
RewriteCond %{REQUEST_URI} !^/wp-content/uploads/thumb_tmp/.*
RewriteCond %{REQUEST_URI} !^/wp-content/uploads/thumb_tmp$
RewriteRule ^wp-content/uploads/(.*)$ http://dingvideo-europe-array.s3.amazonaws.com/wp-content/uploads/$1 [R=301,L]
它通過在上載文件夾上運行重寫規則(不包括thumb_tmp目錄)來工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.