服务器 Gind.cn

服务器问题集锦,包括 Linux(Ubuntu, Centos,Debian等)和Windows Server服务器

Apache重写使用THE_REQUEST只重写GET请求

背景: 为了减less包含wordpress安装的git repos的回购大小,我们从回购中删除静态资产。 大部分工作已经完成,但我有一个障碍。 我已将资产重新定位到S3存储桶,并使用.htaccess RedirectPermanent,以便将本地媒体的请求redirect到s3存储桶。 这是很好的pipe理所有在一个新的地方的现有资产,而无需修改wp数据库。 但是,对于新添加的资产,我们使用“Amazon S3和Cloudfront”插件将它们上传到服务器后自动移动到同一个S3存储桶。 然而,为了工作,我需要使用THE_REQUEST将RedirectPermanent改为RewriteRule,这样只有媒体的GET请求才会指向S3存储桶。 这是因为“Amazon S3和Cloudfront”插件需要允许将文件作为caching本地上传,并从中推送到S3存储桶。 以下是我们目前在.htaccess中的内容: RedirectPermanent /media https://s3-us-west-2.amazonaws.com/bucket/media # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ – [L] RewriteRule ^assets/(.*) /wp-content/themes/theme/assets/$1 [QSA,L] RewriteRule ^plugins/(.*) /wp-content/plugins/$1 [QSA,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> 我对Apache Rewrite规则和条件不是很满意,在格式化比赛正则expression式方面我特别弱,而且我的专业水平和实际编写重写规则的能力也会更好。 我已经阅读了一些关于如何使用THE_REQUEST的在线示例,我知道我需要这样的东西: #there's definitely more that […]