【发布时间】:2018-07-30 13:02:18
【问题描述】:
我们有一个在 Elastic Loadbalancer 后面运行的 AWS beanstalk WordPress 应用程序,并且希望 WP 网站从具有云端的 S3 网站之一打开一个页面,而无需更改地址栏中的 URL。例如 wpbeanstalk.com/xyz 应该打开 s3website.com/a1/page.html。我曾尝试在 Htaccess 中使用 RewriteRule 执行此操作,但 URL 更改为 301,我现在使用 Iframe 在 WP 应用程序上加载 S3website 页面,但这不是一个可行的解决方案。任何人都可以建议实现这一目标的最佳实践吗?
# 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]
RewriteCond %{REQUEST_URI} .ride/$
RewriteRule (.*) awsS3.Website.com/f1/index.html [R=301,L]
</IfModule>
【问题讨论】:
-
请出示您的 RewriteRules。
-
@DusanBajic # BEGIN WordPress
RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d重写规则。 /index.php [L] RewriteCond %{REQUEST_URI} .ride/$ RewriteRule (.*) awsS3.Website.com/f1/index.html [R=301,L] -
如果您将
[R=301,L]更改为[P,L]会发生什么? -
@DusanBajic 我能够使用
[P,L]进行重定向,但是 S3 存储桶网站有一个带有 SSL 证书的 cloundfront,当我点击所需的 URL 时,浏览器会尝试访问 S3 网站但它因 Cloudfront 错误请求而失败。 Cloudfront 设置为 S3 网站 Endpoint 的自定义来源。我想知道如何通过这个 - 请告知您对此的想法。谢谢!
标签: apache .htaccess redirect amazon-s3 amazon-elastic-beanstalk