简体   繁体   English

wordpress wp-content/uploads 文件夹 301 通过 cloudfrond CDN 通过 .htaccess 问题重定向到 S3 存储桶

[英]wordpress wp-content/uploads folder 301 redirect to S3 bucket by cloudfrond CDN by .htaccess issues

See below, the .htacess file from Wordpress.见下文,来自 Wordpress 的 .htacess 文件。 If I remove the part starting from # BEGIN WordPress , all the image file URLs will be changed to d28rt1vkpsdxas.cloudfront.net/someimage.png successfully.如果我删除从# BEGIN WordPress开始的部分,所有图像文件 URL 将成功更改为d28rt1vkpsdxas.cloudfront.net/someimage.png

However, all the internal links will be unable to access (only the home page can access).但是,所有的内部链接将无法访问(只有主页可以访问)。 The error is错误是

Not Found The requested URL /shop/ was not found on this server. Not Found 在此服务器上找不到请求的 URL /shop/。

But if I keep the part start from # BEGIN WordPress , the CDN redirect will not work anymore.但是,如果我将部分从# BEGIN WordPress开始,CDN 重定向将不再起作用。 All photos are missing.所有照片都不见了。

Options +FollowSymlinks

RewriteEngine on

Rewriterule ^wp-content/uploads/(.*)$ http://exampled28t1vkps.cloudfront.net/$1 [r=301,nc]

# 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

您缺少[L]标志,这会阻止其他规则重定向:

Rewriterule ^wp-content/uploads/(.*)$ http://exampled28t1vkps.cloudfront.net/$1 [r=301,nc,l]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM